Use xx-XX format for translation files and default to en-US

Many languages have different variants, so instead of "en" we should be
using "en-US" - this will make it possible to add slightly different
British English translations, for example.
Note that this was already supported for the `locale` config option, we
were simply discarding the part after the dash when looking for the
right translation file.

Also make sure the en-US translations are actually American English,
I'll add en-GB separately.
This commit is contained in:
Linus Groh
2021-02-14 13:12:10 +01:00
parent a9026c7a0a
commit b29cd12ed9
8 changed files with 12 additions and 11 deletions

View File

@@ -142,7 +142,7 @@ unused i18n entries, run:
$ yarn i18n:report
```
To add a new locale, copy `en.json` to `<locale>.json` in [`src/locales`](src/locales)
To add a new locale, copy `en-US.json` to `<locale>.json` in [`src/locales`](src/locales)
and start translating the individual strings. Make sure to [mention the new locale to the docs](docs/config.md#locale)!
For a specific example see commit [`b2edda4`](https://github.com/owntracks/frontend/commit/b2edda410f16633aa6fd9cd4e5250f2031536c7d)

View File

@@ -171,15 +171,16 @@ formats.
Available languages:
- `de` (German)
- `en` (English)
- `es` (Spanish)
- `fr` (French)
- `de-DE` (Standard German)
- `en-US` (American English)
- `es-ES` (Castilian Spanish)
- `fr-FR` (Standard French)
You can use formats like `en-GB`, `en-US`, `de-DE`, `fr-FR`.
Using a locale with non-existent translations is possible and will affect date/time formats, but
use `en-US` for translations.
- Type: [`String`]
- Default: `"en"`
- Default: `"en-US"`
### `map.attribution`

View File

@@ -17,7 +17,7 @@ const DEFAULT_CONFIG = {
minAccuracy: null,
},
ignorePingLocation: true,
locale: "en",
locale: "en-US",
map: {
attribution:
'&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',

View File

@@ -16,8 +16,8 @@ locales.keys().forEach((key) => {
});
export default new VueI18n({
locale: config.locale.split("-")[0],
fallbackLocale: "en",
locale: config.locale,
fallbackLocale: "en-US",
formatFallbackMessages: true,
messages,
});

View File

@@ -10,7 +10,7 @@
"Select user": "Select user",
"Show all": "Show all",
"Select device": "Select device",
"Distance travelled": "Distance travelled",
"Distance travelled": "Distance traveled",
"Download raw data": "Download raw data",
"Information": "Information",
"Show last known locations": "Show last known locations",