diff options
| author | secondl1ght <[email protected]> | 2022-08-16 10:59:19 -0600 |
|---|---|---|
| committer | secondl1ght <[email protected]> | 2022-08-16 10:59:19 -0600 |
| commit | c26e004f4a05f231242587c1265a620b7fcd873a (patch) | |
| tree | 54ac64420712c0343d693b97988a940eda66257e /doc/i18n-technical.md | |
| parent | 94bb8a163f2d1197544977bdbd3c225a815f9c0e (diff) | |
| download | coinos-ui-c26e004f4a05f231242587c1265a620b7fcd873a.tar.gz coinos-ui-c26e004f4a05f231242587c1265a620b7fcd873a.zip | |
run format
Diffstat (limited to 'doc/i18n-technical.md')
| -rw-r--r-- | doc/i18n-technical.md | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/doc/i18n-technical.md b/doc/i18n-technical.md index ea28627e..6c45ee01 100644 --- a/doc/i18n-technical.md +++ b/doc/i18n-technical.md @@ -1,39 +1,40 @@ # CoinOS Internationalization - Technical Information -*NOTE: This documentation was written for people with a technical background. If you do not have a technical background, consider reading [this guide](./i18n.md) instead.* +_NOTE: This documentation was written for people with a technical background. If you do not have a technical background, consider reading [this guide](./i18n.md) instead._ Last Updated: 2022-08-08 ## Dependencies -CoinOS's internationalization system depends on the `npm` package [`svelte-i18n`](https://www.npmjs.com/package/svelte-i18n). Consider reading [its documentation](https://github.com/kaisermann/svelte-i18n/blob/HEAD/docs/Getting%20Started.md) in addition to this. +CoinOS's internationalization system depends on the `npm` package [`svelte-i18n`](https://www.npmjs.com/package/svelte-i18n). Consider reading [its documentation](https://github.com/kaisermann/svelte-i18n/blob/HEAD/docs/Getting%20Started.md) in addition to this. ## Internationalization Code -The main code for CoinOS's internationalization is at `src/lib/i18n.js`. When imported, it does the following: +The main code for CoinOS's internationalization is at `src/lib/i18n.js`. When imported, it does the following: + 1. Load all of the locales [asynchronously](https://github.com/kaisermann/svelte-i18n/blob/main/docs/Getting%20Started.md#32-asynchronous). -2. Pick a locale intelligently, depending on the available locales and the navigator locale, using `pickLocale`. Specifically, if the user's locale (e.g. `en-US`) isn't available but its non-regional version (e.g. `en`) is, the system will use the non-regional locale. +2. Pick a locale intelligently, depending on the available locales and the navigator locale, using `pickLocale`. Specifically, if the user's locale (e.g. `en-US`) isn't available but its non-regional version (e.g. `en`) is, the system will use the non-regional locale. 3. Initialize `svelte-i18n`. -It also defines important constants, including the list of available locales and the default locale. This code is loaded by importing `$lib/i18n` in `src/routes/__layout.svelte`. +It also defines important constants, including the list of available locales and the default locale. This code is loaded by importing `$lib/i18n` in `src/routes/__layout.svelte`. ## Locale Files -Each locale in `coinos-ui-v2` is defined by a JSON file in `src/locales`. Its name is the locale's [ISO 639-1 code](https://en.wikipedia.org/wiki/ISO_639-1) plus `.json`. It is simply a file that maps string IDs to translated strings. Here is an example of `en.json`: +Each locale in `coinos-ui-v2` is defined by a JSON file in `src/locales`. Its name is the locale's [ISO 639-1 code](https://en.wikipedia.org/wiki/ISO_639-1) plus `.json`. It is simply a file that maps string IDs to translated strings. Here is an example of `en.json`: ```json { - "howItWorks": "How It Works", - "faq": "FAQ", - "about": "About", - "startInSeconds": "Start in Seconds", - "signIn": "Sign In" + "howItWorks": "How It Works", + "faq": "FAQ", + "about": "About", + "startInSeconds": "Start in Seconds", + "signIn": "Sign In" } ``` ## Internationalizing Strings -Strings are internationalized by simply using `svelte-i18n`'s [`$format`](https://github.com/kaisermann/svelte-i18n/blob/96a5adab7560249c8881e0612454e01c09273400/docs/Formatting.md) function. A localized string looks like this: +Strings are internationalized by simply using `svelte-i18n`'s [`$format`](https://github.com/kaisermann/svelte-i18n/blob/96a5adab7560249c8881e0612454e01c09273400/docs/Formatting.md) function. A localized string looks like this: ``` {$_('stringID')} @@ -43,4 +44,4 @@ Strings are internationalized by simply using `svelte-i18n`'s [`$format`](https: ## The Locale Selector -CoinOS also has a `LocaleSelector` component, which should be used to select locales. It is a dropdown that allows you to select & update the locale. +CoinOS also has a `LocaleSelector` component, which should be used to select locales. It is a dropdown that allows you to select & update the locale. |
