Rename en-GB language to en (#2866)

Fixes https://github.com/element-hq/element-call/issues/2865

If we want to have GB and US specific terms later on we can then add then in as `en-GB` and `en-US`.
This commit is contained in:
Hugh Nimmo-Smith
2024-12-04 14:51:29 +00:00
committed by GitHub
parent 68867810f7
commit 27620b9148
8 changed files with 17 additions and 20 deletions

View File

@@ -220,7 +220,7 @@ To add a new translation key you can do these steps:
1. Add the new key entry to the code where the new key is used: `t("some_new_key")` 1. Add the new key entry to the code where the new key is used: `t("some_new_key")`
1. Run `yarn i18n` to extract the new key and update the translation files. This 1. Run `yarn i18n` to extract the new key and update the translation files. This
will add a skeleton entry to the `locales/en-GB/app.json` file: will add a skeleton entry to the `locales/en/app.json` file:
```jsonc ```jsonc
{ {
... ...
@@ -228,7 +228,7 @@ To add a new translation key you can do these steps:
... ...
} }
``` ```
1. Update the skeleton entry in the `locales/en-GB/app.json` file with 1. Update the skeleton entry in the `locales/en/app.json` file with
the English translation: the English translation:
```jsonc ```jsonc

View File

@@ -21,7 +21,7 @@ export default {
}, },
], ],
}, },
locales: ["en-GB"], locales: ["en"],
output: "locales/$LOCALE/$NAMESPACE.json", output: "locales/$LOCALE/$NAMESPACE.json",
input: ["src/**/*.{ts,tsx}"], input: ["src/**/*.{ts,tsx}"],
sort: true, sort: true,

View File

@@ -7,13 +7,13 @@
"features": ["plural_postfix_us", "filter_untranslated"], "features": ["plural_postfix_us", "filter_untranslated"],
"files": [ "files": [
{ {
"pattern": "locales/en-GB/*.json", "pattern": "locales/en/*.json",
"lang": "inherited" "lang": "inherited"
}, },
{ {
"group": "existing", "group": "existing",
"pattern": "locales/*/*.json", "pattern": "locales/*/*.json",
"excludes": ["locales/en-GB/*.json"], "excludes": ["locales/en/*.json"],
"lang": "${autodetectLang}" "lang": "${autodetectLang}"
} }
] ]
@@ -25,9 +25,6 @@
"output": "locales/${langLsrDash}/${file}" "output": "locales/${langLsrDash}/${file}"
} }
], ],
"includeSourceLang": "${includeSourceLang|false}", "includeSourceLang": "${includeSourceLang|false}"
"langAliases": {
"en": "en_GB"
}
} }
} }

View File

@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
import "i18next"; import "i18next";
// import all namespaces (for the default language, only) // import all namespaces (for the default language, only)
import app from "../../locales/en-GB/app.json"; import app from "../../locales/en/app.json";
declare module "i18next" { declare module "i18next" {
interface CustomTypeOptions { interface CustomTypeOptions {

View File

@@ -22,7 +22,7 @@ export abstract class TranslatedError extends Error {
messageKey: ParseKeys<DefaultNamespace, TOptions>, messageKey: ParseKeys<DefaultNamespace, TOptions>,
translationFn: TFunction<DefaultNamespace>, translationFn: TFunction<DefaultNamespace>,
) { ) {
super(translationFn(messageKey, { lng: "en-GB" } as TOptions)); super(translationFn(messageKey, { lng: "en" } as TOptions));
this.translatedMessage = translationFn(messageKey); this.translatedMessage = translationFn(messageKey);
} }
} }

View File

@@ -24,7 +24,7 @@ import { platform } from "./Platform";
// This generates a map of locale names to their URL (based on import.meta.url), which looks like this: // This generates a map of locale names to their URL (based on import.meta.url), which looks like this:
// { // {
// "../locales/en-GB/app.json": "/whatever/assets/root/locales/en-aabbcc.json", // "../locales/en/app.json": "/whatever/assets/root/locales/en-aabbcc.json",
// ... // ...
// } // }
const locales = import.meta.glob<string>("../locales/*/*.json", { const locales = import.meta.glob<string>("../locales/*/*.json", {
@@ -41,7 +41,7 @@ const getLocaleUrl = (
const supportedLngs = [ const supportedLngs = [
...new Set( ...new Set(
Object.keys(locales).map((url) => { Object.keys(locales).map((url) => {
// The URLs are of the form ../locales/en-GB/app.json // The URLs are of the form ../locales/en/app.json
// This extracts the language code from the URL // This extracts the language code from the URL
const lang = url.match(/\/([^/]+)\/[^/]+\.json$/)?.[1]; const lang = url.match(/\/([^/]+)\/[^/]+\.json$/)?.[1];
if (!lang) { if (!lang) {
@@ -133,7 +133,7 @@ export class Initializer {
.use(languageDetector) .use(languageDetector)
.use(initReactI18next) .use(initReactI18next)
.init({ .init({
fallbackLng: "en-GB", fallbackLng: "en",
defaultNS: "app", defaultNS: "app",
keySeparator: ".", keySeparator: ".",
nsSeparator: false, nsSeparator: false,

View File

@@ -17,20 +17,20 @@ import "vitest-axe/extend-expect";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import "@testing-library/jest-dom/vitest"; import "@testing-library/jest-dom/vitest";
import EN_GB from "../locales/en-GB/app.json"; import EN from "../locales/en/app.json";
import { Config } from "./config/Config"; import { Config } from "./config/Config";
// Bare-minimum i18n config // Bare-minimum i18n config
i18n i18n
.use(initReactI18next) .use(initReactI18next)
.init({ .init({
lng: "en-GB", lng: "en",
fallbackLng: "en-GB", fallbackLng: "en",
supportedLngs: ["en-GB"], supportedLngs: ["en"],
// We embed the translations, so that it never needs to fetch // We embed the translations, so that it never needs to fetch
resources: { resources: {
"en-GB": { en: {
app: EN_GB, app: EN,
}, },
}, },
interpolation: { interpolation: {