aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2022-08-23 14:20:26 -0500
committerAdrien Hopkins <[email protected]>2022-08-23 14:20:26 -0500
commitbd132fd1e54c07b7ff228132c03979e9594d5df1 (patch)
tree0fd1426b282299cee8866f054a6746958683a0c6 /doc
parent82929040dc83ce13d058f4e81a0e8bca45173000 (diff)
downloadcoinos-ui-bd132fd1e54c07b7ff228132c03979e9594d5df1.tar.gz
coinos-ui-bd132fd1e54c07b7ff228132c03979e9594d5df1.zip
updated technical i18n documentation for sveltekit-i18n
Diffstat (limited to 'doc')
-rw-r--r--doc/i18n-technical.md18
1 files changed, 8 insertions, 10 deletions
diff --git a/doc/i18n-technical.md b/doc/i18n-technical.md
index a0d64938..46fbb094 100644
--- a/doc/i18n-technical.md
+++ b/doc/i18n-technical.md
@@ -2,21 +2,20 @@
_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
+Last Updated: 2022-08-23
## 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 [`sveltekit-i18n`](https://www.npmjs.com/package/sveltekit-i18n). Consider reading [its documentation](https://github.com/sveltekit-i18n/lib/tree/master/docs/README.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/translations/index.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.
-3. Initialize `svelte-i18n`.
+1. Load all of the locales asynchronously, based on .
+3. Initialize `sveltekit-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/translations` in `src/routes/+layout.svelte`. This code, which runs in the frontend, also persists the locale in `localStorage`.
## Locale Files
@@ -34,14 +33,12 @@ Each locale in `coinos-ui-v2` is defined by a JSON file in `src/locales`. Its na
## 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 `sveltekit-i18n`'s `$t` function. A localized string looks like this:
```
{$t('stringID')}
```
-(`$_` is a convenient alias for `$format`.)
-
## 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.
@@ -51,4 +48,5 @@ CoinOS also has a `LocaleSelector` component, which should be used to select loc
CoinOS has a Python script that helps you with the technical parts of translation. It is located at `src/locales/guided_translation.py`. It also has some utility functions:
- `nested_dict_keys` - gets a list of keys of a nested dictionary in dot-separated shallow format (e.g. a.b.c)
+- `create_locale` - adds a new locale to the lang.json file
- `localize_string` - localizes a string interactively