Skip to content

Commit e1dab17

Browse files
Update frontend/viewer/src/locales (#1855)
* Update frontend/viewer/src/locales * change i18n file format to .po files which are better supported by Crowdin --------- Co-authored-by: Kevin Hahn <kevin_hahn@sil.org>
1 parent 388c333 commit e1dab17

14 files changed

Lines changed: 4710 additions & 11960 deletions

File tree

backend/FwLite/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tasks:
1414
dir: ./FwLiteWeb
1515
cmd: dotnet watch --no-hot-reload
1616
web-prod:
17-
deps: [ ui:build-viewer-app ]
17+
deps: [ ui:build-viewer ]
1818
dir: ./FwLiteWeb
1919
cmd: dotnet run -- --FwLite:UseDevAssets=false
2020
web-chaos:

frontend/viewer/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
Typical development workflow should be to run `task fw-lite-web` in the repo root.
22

3-
### i18n
3+
### i18n
44

55
We're using a different library here from the lexbox UI. The core lib is https://lingui.dev/
66
with a Svelte plugin https://github.com/HenryLie/svelte-i18n-lingui
77

88
Basic usage looks like this:
9+
910
```sveltehtml
1011
<span>{$t`Logout`}</span>
1112
```
12-
for the english text 'Logout'. Then to make localization files run:
13+
14+
for the English text 'Logout'. Then to make localization files, run:
15+
1316
```bash
1417
pnpm run i18n:extract
1518
```
19+
1620
This will update the files under `/src/locales/`. If you want, you can then feed those files to an AI and it will translate them for you.
1721

1822
#### Adding a new language
19-
The `/src/locales/` folder contains one file per language, named using its language code (e.g. `es.json` for Spanish).
20-
You must update `frontend/viewer/lingui.config.ts` with the additional language code, then run `pnpm run i18n:extract` to generate the new locale file
23+
24+
The `/src/locales/` folder contains one file per language, named using its language code (e.g., `es.json` for Spanish).
25+
You must update `frontend/viewer/lingui.config.ts` with the additional language code, then run `pnpm run i18n:extract` to generate the new locale file.
2126

2227
#### Advanced Usage
2328

24-
for formatted values you can do this:
29+
For formatted values you can do this:
30+
2531
```sveltehtml
2632
<span>{$t`Hello ${name}, how are you today?`}</span>
2733
```
2834

2935
### ShadCN
3036

31-
add a new component
37+
Add a new component with this:
38+
3239
```bash
3340
pnpx shadcn-svelte@next add context-menu
3441
```

frontend/viewer/lingui.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import {jstsExtractor, svelteExtractor} from 'svelte-i18n-lingui/extractor';
22

33
import {defineConfig} from '@lingui/cli';
4-
import {formatter} from '@lingui/format-json';
54

65
export default defineConfig({
7-
format: formatter({style: 'lingui'}),
86
locales: ['en', 'es', 'fr', 'ko', 'id'],
97
sourceLocale: 'en',
108
catalogs: [

frontend/viewer/src/lib/i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export async function setLanguage(lang: string): Promise<void> {
66
const wasDefault = lang === 'default';
77
if (!lang || wasDefault) lang = localStorage.getItem('locale') ?? 'en';
88
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
9-
const {messages} = await import(`../../locales/${lang}.json?lingui`);
9+
const {messages} = await import(`../../locales/${lang}.po?lingui`);
1010
locale.set(lang, messages);
1111
//only save when the user changes locale
1212
if (!wasDefault) localStorage.setItem('locale', lang);

0 commit comments

Comments
 (0)