Skip to content

Commit b381508

Browse files
antsgarL10n bot
andauthored
chore: Translations fixes (#3066)
* chore: Fixes unwrapped strings for backups frequency * fix: Fixes spotlight modal auto-dismissing when prefs sync * feat: Adds spotlight to language pref section * fix: Fixes dropdown showing old value while switching languages * fix: Preloads language list before toggle is enabled * chore: Renames methods * i18n(weekly-mr): Upgrade translations from crowdin (376c138a). --------- Co-authored-by: L10n bot <service_account_73c4205ebb9a547d11aa5c7b26226660@noreply.gitlab.protontech.ch>
1 parent 7a6f8b8 commit b381508

24 files changed

Lines changed: 1285 additions & 35 deletions

File tree

‎packages/.locale-state.metadata‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"project": "fe-standardnotes",
3-
"locale": "ac161306578fcd17ec1c93f67b26c6d4516d4232"
3+
"locale": "2286337811ccb410464f7a06c72d2fd778ec17d4"
44
}

‎packages/desktop/locales/de_DE.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"Close": [
103103
"Schließen"
104104
],
105+
"Close Window": [
106+
"Fenster schließen"
107+
],
105108
"Copy": [
106109
"Kopieren"
107110
],

‎packages/desktop/locales/es_LA.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"Close": [
103103
"Cerrar"
104104
],
105+
"Close Window": [
106+
"Cerrar ventana"
107+
],
105108
"Copy": [
106109
"Copiar"
107110
],

‎packages/desktop/locales/fr_FR.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"Close": [
103103
"Fermer"
104104
],
105+
"Close Window": [
106+
"Fermer la fenêtre"
107+
],
105108
"Copy": [
106109
"Copier"
107110
],

‎packages/desktop/locales/ja_JP.json‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
"(1) Update Available": [
7676
"(1) 更新が利用可能です"
7777
],
78+
"About ${ appName }": [
79+
"${ appName }について"
80+
],
81+
"Actual Size": [
82+
"実際のサイズ"
83+
],
7884
"Automatic Updates Disabled": [
7985
"自動更新は無効化されています"
8086
],
@@ -96,6 +102,15 @@
96102
"Close": [
97103
"閉じる"
98104
],
105+
"Close Window": [
106+
"ウインドウを閉じる"
107+
],
108+
"Copy": [
109+
"コピー"
110+
],
111+
"Cut": [
112+
"カット"
113+
],
99114
"Disable Automatic Backups": [
100115
"自動バックアップを無効化"
101116
],
@@ -120,9 +135,18 @@
120135
"GitHub": [
121136
"GitHub"
122137
],
138+
"Help": [
139+
"ヘルプ"
140+
],
141+
"Hide ${ appName }": [
142+
"${ appName }を非表示にする"
143+
],
123144
"Hide Menu Bar": [
124145
"メニューバーを隠す"
125146
],
147+
"Hide Others": [
148+
"他を非表示"
149+
],
126150
"Install Pending Update (${ versionNumber })": [
127151
"保留中の更新をインストール (${ versionNumber })"
128152
],
@@ -141,21 +165,60 @@
141165
"Open Download Location": [
142166
"ダウンロード先を開く"
143167
],
168+
"Paste": [
169+
"貼り付け"
170+
],
171+
"Paste and Match Style": [
172+
"書式を統一して貼り付け"
173+
],
174+
"Quit ${ appName }": [
175+
"${ appName } を終了する"
176+
],
177+
"Redo": [
178+
"やり直す"
179+
],
144180
"Release Notes": [
145181
"更新情報"
146182
],
183+
"Reload": [
184+
"再読み込み"
185+
],
186+
"Select All": [
187+
"すべて選択"
188+
],
189+
"Services": [
190+
"サービス"
191+
],
192+
"Show All": [
193+
"すべて表示"
194+
],
147195
"Speech": [
148196
"読み上げ"
149197
],
150198
"Spellchecker Languages": [
151199
"スペルチェッカーの言語"
152200
],
201+
"Start Speaking": [
202+
"読み上げを開始"
203+
],
204+
"Stop Speaking": [
205+
"読み上げを停止"
206+
],
207+
"Toggle Developer Tools": [
208+
"開発者ツールを切り替える"
209+
],
153210
"Toggle Error Console": [
154211
"エラーコンソールを切り替え"
155212
],
213+
"Toggle Full Screen": [
214+
"フルスクリーンに切り替え"
215+
],
156216
"Twitter": [
157217
"Twitter"
158218
],
219+
"Undo": [
220+
"元に戻す"
221+
],
159222
"Updates": [
160223
"更新"
161224
],
@@ -171,8 +234,17 @@
171234
"Website": [
172235
"ウェブサイト"
173236
],
237+
"Window": [
238+
"ウィンドウ"
239+
],
174240
"Zoom": [
175241
"Zoom"
242+
],
243+
"Zoom In": [
244+
"拡大"
245+
],
246+
"Zoom Out": [
247+
"縮小"
176248
]
177249
},
178250
"B8.MobileDesktopShared.Desktop.Menu.Title": {

‎packages/desktop/locales/pt_BR.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"Close": [
103103
"Fechar"
104104
],
105+
"Close Window": [
106+
"Fechar janela"
107+
],
105108
"Copy": [
106109
"Copiar"
107110
],

‎packages/desktop/locales/tr_TR.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
"Close": [
103103
"Kapat"
104104
],
105+
"Close Window": [
106+
"Pencereyi kapat"
107+
],
105108
"Copy": [
106109
"Kopyala"
107110
],

‎packages/desktop/locales/zh_CN.json‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
"(1) Update Available": [
7676
"(1) 有可用更新"
7777
],
78+
"About ${ appName }": [
79+
"关于 ${ appName }"
80+
],
81+
"Actual Size": [
82+
"实际大小"
83+
],
7884
"Automatic Updates Disabled": [
7985
"自动更新已停用"
8086
],
@@ -96,6 +102,15 @@
96102
"Close": [
97103
"关闭"
98104
],
105+
"Close Window": [
106+
"关闭窗口"
107+
],
108+
"Copy": [
109+
"复制"
110+
],
111+
"Cut": [
112+
"剪切"
113+
],
99114
"Disable Automatic Backups": [
100115
"停用自动备份"
101116
],
@@ -120,9 +135,18 @@
120135
"GitHub": [
121136
"GitHub"
122137
],
138+
"Help": [
139+
"帮助"
140+
],
141+
"Hide ${ appName }": [
142+
"隐藏 ${ appName }"
143+
],
123144
"Hide Menu Bar": [
124145
"隐藏菜单栏"
125146
],
147+
"Hide Others": [
148+
"隐藏其他"
149+
],
126150
"Install Pending Update (${ versionNumber })": [
127151
"安装待处理的更新 (${ versionNumber })"
128152
],
@@ -141,21 +165,60 @@
141165
"Open Download Location": [
142166
"打开下载位置"
143167
],
168+
"Paste": [
169+
"粘贴"
170+
],
171+
"Paste and Match Style": [
172+
"粘贴并匹配样式"
173+
],
174+
"Quit ${ appName }": [
175+
"退出 ${ appName }"
176+
],
177+
"Redo": [
178+
"重做"
179+
],
144180
"Release Notes": [
145181
"版本说明"
146182
],
183+
"Reload": [
184+
"重新加载"
185+
],
186+
"Select All": [
187+
"全选"
188+
],
189+
"Services": [
190+
"服务"
191+
],
192+
"Show All": [
193+
"显示全部"
194+
],
147195
"Speech": [
148196
"语音"
149197
],
150198
"Spellchecker Languages": [
151199
"拼写检查语言"
152200
],
201+
"Start Speaking": [
202+
"开始说话"
203+
],
204+
"Stop Speaking": [
205+
"停止说话"
206+
],
207+
"Toggle Developer Tools": [
208+
"切换开发者工具"
209+
],
153210
"Toggle Error Console": [
154211
"切换错误控制台"
155212
],
213+
"Toggle Full Screen": [
214+
"切换至全屏"
215+
],
156216
"Twitter": [
157217
"Twitter"
158218
],
219+
"Undo": [
220+
"撤消"
221+
],
159222
"Updates": [
160223
"更新"
161224
],
@@ -171,8 +234,17 @@
171234
"Website": [
172235
"网站"
173236
],
237+
"Window": [
238+
"窗口"
239+
],
174240
"Zoom": [
175241
"缩放"
242+
],
243+
"Zoom In": [
244+
"放大"
245+
],
246+
"Zoom Out": [
247+
"缩小"
176248
]
177249
},
178250
"B8.MobileDesktopShared.Desktop.Menu.Title": {

‎packages/i18n/src/LocaleService.spec.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ describe('LocaleService', () => {
7979
expect(fetchMock).toHaveBeenCalledTimes(1)
8080
})
8181

82+
it('shares an in-flight locale catalog request', async () => {
83+
const fetchMock = createFetchMock({
84+
'/locales/config/locales.json': catalog,
85+
})
86+
global.fetch = fetchMock
87+
88+
const service = new LocaleService()
89+
90+
await Promise.all([service.getAvailableLocales(), service.getAvailableLocales()])
91+
92+
expect(fetchMock).toHaveBeenCalledTimes(1)
93+
})
94+
95+
it('retries the locale catalog after a failed request', async () => {
96+
const loadJson = jest.fn().mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce(catalog)
97+
const service = new LocaleService({ loadJson })
98+
99+
await expect(service.getAvailableLocales()).rejects.toThrow('offline')
100+
await expect(service.getAvailableLocales()).resolves.toEqual(catalog)
101+
})
102+
82103
it('loads translations and activates a locale', async () => {
83104
const onLocaleChanged = jest.fn()
84105
global.fetch = createFetchMock({

‎packages/i18n/src/LocaleService.ts‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ export type LocaleCatalog = Record<string, string>
1010

1111
export type LocaleServiceOptions = {
1212
onLocaleChanged?: (locale: string) => void
13-
fetchJson?: <T>(url: string) => Promise<T>
13+
loadJson?: <T>(url: string) => Promise<T>
1414
localesBasePath?: string
1515
}
1616

1717
export class LocaleService {
1818
private currentLocale = DEFAULT_LOCALE
19-
private catalog?: LocaleCatalog
19+
private catalog?: Promise<LocaleCatalog>
2020
private readonly loadedLocales = new Set<string>()
2121
private readonly onLocaleChanged?: (locale: string) => void
22-
private readonly fetchJsonImpl: <T>(url: string) => Promise<T>
22+
private readonly loadJson: <T>(url: string) => Promise<T>
2323
private readonly localesBasePath: string
2424

2525
constructor(options: LocaleServiceOptions = {}) {
2626
this.onLocaleChanged = options.onLocaleChanged
27-
this.fetchJsonImpl = options.fetchJson ?? this.fetchJsonWithHttp.bind(this)
27+
this.loadJson = options.loadJson ?? this.fetchJsonWithHttp.bind(this)
2828
this.localesBasePath = options.localesBasePath ?? LOCALES_BASE_PATH
2929
setDefaultLang(DEFAULT_LOCALE)
3030
}
@@ -38,19 +38,21 @@ export class LocaleService {
3838
return this.currentLocale
3939
}
4040

41-
async getAvailableLocales(): Promise<LocaleCatalog> {
42-
if (this.catalog) {
43-
return this.catalog
41+
getAvailableLocales(): Promise<LocaleCatalog> {
42+
if (!this.catalog) {
43+
this.catalog = this.loadJson<LocaleCatalog>(this.localeResourcePath('config/locales.json'))
44+
this.catalog.catch(() => {
45+
this.catalog = undefined
46+
})
4447
}
4548

46-
this.catalog = await this.fetchJsonImpl<LocaleCatalog>(this.localeResourcePath('config/locales.json'))
4749
return this.catalog
4850
}
4951

5052
/** Loads locale JSON if needed and activates it. Throws when the pack cannot be loaded. */
5153
async loadAndActivateLocale(locale: string): Promise<void> {
5254
if (locale !== DEFAULT_LOCALE && !this.loadedLocales.has(locale)) {
53-
const data = await this.fetchJsonImpl<LocaleData>(this.localeResourcePath(`${locale}.json`))
55+
const data = await this.loadJson<LocaleData>(this.localeResourcePath(`${locale}.json`))
5456
addLocale(locale, data)
5557
this.loadedLocales.add(locale)
5658
}

0 commit comments

Comments
 (0)