@@ -10,10 +10,9 @@ for different account related information
10
10
and configuration.
11
11
*/
12
12
13
- import { useState } from "react" ;
14
- import { DownOutlined } from "@ant-design/icons" ;
15
- import { Button , Dropdown , MenuProps , Modal , Space , Tooltip } from "antd" ;
13
+ import { Space } from "antd" ;
16
14
import { useIntl } from "react-intl" ;
15
+
17
16
import { SignOut } from "@cocalc/frontend/account/sign-out" ;
18
17
import { AntdTabItem , Col , Row , Tabs } from "@cocalc/frontend/antd-bootstrap" ;
19
18
import {
@@ -22,17 +21,10 @@ import {
22
21
useTypedRedux ,
23
22
useWindowDimensions ,
24
23
} from "@cocalc/frontend/app-framework" ;
25
- import { useLocalizationCtx } from "@cocalc/frontend/app/localize" ;
26
- import { Icon , Loading , Paragraph } from "@cocalc/frontend/components" ;
24
+ import { Icon , Loading } from "@cocalc/frontend/components" ;
27
25
import { cloudFilesystemsEnabled } from "@cocalc/frontend/compute" ;
28
26
import CloudFilesystems from "@cocalc/frontend/compute/cloud-filesystem/cloud-filesystems" ;
29
- import {
30
- getLocale ,
31
- labels ,
32
- Locale ,
33
- LOCALIZATIONS ,
34
- OTHER_SETTINGS_LOCALE_KEY ,
35
- } from "@cocalc/frontend/i18n" ;
27
+ import { labels } from "@cocalc/frontend/i18n" ;
36
28
import { LandingPage } from "@cocalc/frontend/landing-page/landing-page" ;
37
29
import { local_storage_length } from "@cocalc/frontend/misc/local-storage" ;
38
30
import PurchasesPage from "@cocalc/frontend/purchases/purchases-page" ;
@@ -44,19 +36,18 @@ import {
44
36
KUCALC_ON_PREMISES ,
45
37
} from "@cocalc/util/db-schema/site-defaults" ;
46
38
import { AccountPreferences } from "./account-preferences" ;
39
+ import { I18NSelector } from "./i18n-selector" ;
47
40
import { LicensesPage } from "./licenses/licenses-page" ;
48
41
import { PublicPaths } from "./public-paths/public-paths" ;
49
42
import { SSHKeysPage } from "./ssh-keys/global-ssh-keys" ;
50
43
import { UpgradesPage } from "./upgrades/upgrades-page" ;
51
44
52
45
export const AccountPage : React . FC = ( ) => {
53
46
const intl = useIntl ( ) ;
54
- const { setLocale, locale } = useLocalizationCtx ( ) ;
55
47
56
48
const { width : windowWidth } = useWindowDimensions ( ) ;
57
49
const isWide = windowWidth > 800 ;
58
50
59
- const other_settings = useTypedRedux ( "account" , "other_settings" ) ;
60
51
const active_page = useTypedRedux ( "account" , "active_page" ) ;
61
52
const is_logged_in = useTypedRedux ( "account" , "is_logged_in" ) ;
62
53
const account_id = useTypedRedux ( "account" , "account_id" ) ;
@@ -85,8 +76,6 @@ export const AccountPage: React.FC = () => {
85
76
const ssh_gateway = useTypedRedux ( "customize" , "ssh_gateway" ) ;
86
77
const is_commercial = useTypedRedux ( "customize" , "is_commercial" ) ;
87
78
const get_api_key = useTypedRedux ( "page" , "get_api_key" ) ;
88
- const i18n_enabled = useTypedRedux ( "customize" , "i18n" ) ;
89
- const [ langOpen , setLangOpen ] = useState < boolean > ( false ) ;
90
79
91
80
// for each exclusive domain, tell the user which strategy to use
92
81
const exclusive_sso_domains = React . useMemo ( ( ) => {
@@ -264,126 +253,10 @@ export const AccountPage: React.FC = () => {
264
253
return items ;
265
254
}
266
255
267
- function renderI18N ( ) : JSX . Element | null {
268
- if (
269
- i18n_enabled == null ||
270
- i18n_enabled . isEmpty ( ) ||
271
- ( i18n_enabled . size === 1 && i18n_enabled . includes ( "en" ) )
272
- ) {
273
- return null ;
274
- }
275
-
276
- const i18n : Locale = getLocale ( other_settings ) ;
277
-
278
- const items : MenuProps [ "items" ] =
279
- Object . entries ( LOCALIZATIONS )
280
- . filter ( ( [ key , _ ] ) => i18n_enabled . includes ( key as any ) )
281
- . map ( ( [ key , { name, trans, native, flag } ] ) => {
282
- const other = key === locale ? name : intl . formatMessage ( trans ) ;
283
- return { key, label : `${ flag } ${ native } (${ other } )` } ;
284
- } ) ?? [ ] ;
285
-
286
- items . push ( { type : "divider" } ) ;
287
- items . push ( {
288
- key : "help" ,
289
- label : (
290
- < Space >
291
- < Icon name = "translation-outlined" />
292
- { intl . formatMessage ( {
293
- id : "account.account_page.translation.info.label" ,
294
- defaultMessage : "Translation Info..." ,
295
- description : "Label of translation information modal in dropdown" ,
296
- } ) }
297
- </ Space >
298
- ) ,
299
- onClick : ( ) =>
300
- Modal . info ( {
301
- width : "min(90vw, 600px)" ,
302
- title : intl . formatMessage ( {
303
- id : "account.account_page.translation.info.title" ,
304
- defaultMessage : "Translation Information" ,
305
- description : "Title of translation information modal" ,
306
- } ) ,
307
- content : (
308
- < Paragraph >
309
- { intl . formatMessage ( {
310
- id : "account.account_page.translation.info.content" ,
311
- defaultMessage : `
312
- We're excited to start offering our application in multiple languages! Here's what you need to know:
313
-
314
- <ul>
315
- <li><b>Work in Progress</b>: Our translation effort is just beginning. Many parts of the application are not yet translated.</li>
316
- <li><b>Gradual Improvement</b>: We're continuously working to expand our language coverage. You'll see more content translated over time.</li>
317
- <li><b>Your Help is Welcome</b>: We value our community's input. If you're fluent in multiple languages and would like to contribute to our translation efforts, we'd love to hear from you!</li>
318
- <li><b>Contact Us</b>: To learn more about contributing to translations or to report any issues, please reach out to our support team.</li>
319
- </ul>
320
-
321
- Thank you for your patience and understanding as we work to make our application accessible to a global audience!` ,
322
- description : "Content of translation information modal" ,
323
- } ) }
324
- </ Paragraph >
325
- ) ,
326
- } ) ,
327
- } ) ;
328
-
329
- const menu : MenuProps = {
330
- items,
331
- style : { maxHeight : "75vh" , overflow : "auto" } ,
332
- onClick : ( { key } ) => {
333
- if ( key in LOCALIZATIONS ) {
334
- redux
335
- . getActions ( "account" )
336
- . set_other_settings ( OTHER_SETTINGS_LOCALE_KEY , key ) ;
337
- setLocale ( key ) ;
338
- }
339
- } ,
340
- } ;
341
-
342
- const lang_icon = LOCALIZATIONS [ i18n ] ?. flag ;
343
-
344
- const title =
345
- i18n in LOCALIZATIONS
346
- ? intl . formatMessage ( LOCALIZATIONS [ i18n ] . trans )
347
- : i18n ;
348
-
349
- const cur = `${ title } (${ LOCALIZATIONS [ i18n ] ?. name ?? i18n } )` ;
350
- const msg = intl . formatMessage ( labels . account_language_tooltip ) ;
351
- const tooltip = (
352
- < >
353
- { cur }
354
- < br />
355
- { msg }
356
- { labels . account_language_tooltip . defaultMessage != msg ? (
357
- < >
358
- < br /> ({ labels . account_language_tooltip . defaultMessage } )
359
- </ >
360
- ) : undefined }
361
- </ >
362
- ) ;
363
-
364
- return (
365
- < Tooltip title = { langOpen ? undefined : tooltip } trigger = { [ "hover" ] } >
366
- < Dropdown
367
- menu = { menu }
368
- trigger = { [ "click" ] }
369
- onOpenChange = { ( open ) => setLangOpen ( open ) }
370
- >
371
- < Button >
372
- < Space >
373
- { lang_icon }
374
- { isWide ? title : undefined }
375
- < DownOutlined />
376
- </ Space >
377
- </ Button >
378
- </ Dropdown >
379
- </ Tooltip >
380
- ) ;
381
- }
382
-
383
256
function renderExtraContent ( ) {
384
257
return (
385
258
< Space >
386
- { renderI18N ( ) }
259
+ < I18NSelector isWide = { isWide } />
387
260
< SignOut everywhere = { false } highlight = { true } narrow = { ! isWide } />
388
261
</ Space >
389
262
) ;
0 commit comments