diff --git a/README.md b/README.md index f321580..0dc42c3 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,13 @@ [IETF language tags](https://en.wikipedia.org/wiki/IETF_language_tag). Short tags (e.g. `en` instead of `en-GB`) are preferred. -**IMPORTANT:** If you are adding a new language, you **must** add it to -[`src/utils/i18n.ts`](src/utils/i18n.ts) in `supportedLngs`. Be sure to add -yourself to [`translators.json`](translators.json) too! +**IMPORTANT:** If you are adding a new language, you **must**: + +* Add the language code to [`src/utils/i18n.ts`](src/utils/i18n.ts) in + `supportedLngs` +* Add a listing for the language with the English name, native name, a country + code (for the flag) and the contributors list to + [`languages.json`](languages.json) The library will automatically detect the language from your browser to use, but for the sake of testing, you can override it by running the following command in diff --git a/languages.json b/languages.json new file mode 100644 index 0000000..209c45d --- /dev/null +++ b/languages.json @@ -0,0 +1,46 @@ +{ + "en": { + "name": "English (GB)", + "country": "GB", + "contributors": [] + }, + "de": { + "name": "German", + "nativeName": "Deutsch", + "country": "de", + "contributors": [ + { + "name": "Lignum", + "url": "https://github.com/Lignum" + } + ] + }, + "fr": { + "name": "French", + "nativeName": "Français", + "country": "fr", + "contributors": [ + { + "name": "Anavrins", + "url": "https://github.com/xAnavrins" + } + ] + }, + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "country": "jp", + "contributors": [] + }, + "vi": { + "name": "Vietnamese", + "nativeName": "Tiếng Việt", + "country": "vn", + "contributors": [ + { + "name": "Boom", + "url": "https://github.com/signalhunter" + } + ] + } +} diff --git a/package-lock.json b/package-lock.json index 86ecd9e..8151d2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9056,9 +9056,9 @@ "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-forge": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", - "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==" + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", + "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" }, "node-gyp": { "version": "3.8.0", @@ -12425,11 +12425,11 @@ "integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=" }, "selfsigned": { - "version": "1.10.7", - "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-1.10.7.tgz", - "integrity": "sha512-8M3wBCzeWIJnQfl43IKwOmC4H/RAp50S8DF60znzjW5GVqTcSe2vWclt7hmYVPkKPlHWOu5EaWOMZ2Y6W8ZXTA==", + "version": "1.10.8", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-1.10.8.tgz", + "integrity": "sha512-2P4PtieJeEwVgTU9QEcwIRDQ/mXJLX8/+I3ur+Pg16nS8oNbrGxEso9NyYWy8NAmXiNl4dlAp5MwoNeCWzON4w==", "requires": { - "node-forge": "0.9.0" + "node-forge": "^0.10.0" } }, "semver": { diff --git a/src/layouts/credits/Translators.tsx b/src/layouts/credits/Translators.tsx index 8f0d1fb..5f7f646 100644 --- a/src/layouts/credits/Translators.tsx +++ b/src/layouts/credits/Translators.tsx @@ -8,13 +8,37 @@ import packageJson from "@/package.json"; -// Find translators.json -const req = require.context("@/", false, /\.\/translators.json$/); +// Find languages.json +const req = require.context("@/", false, /\.\/languages.json$/); -interface Translator { +interface Language { + name: string; + nativeName?: string; + country?: string; + contributors?: Contributor[]; +}; + +interface Contributor { name: string; url?: string; -}; +} + +const ContributorComponent: React.FC = ({ name, url }: Contributor) => ( + url + ? {name} + : {name} +); + +const LanguageComponent: React.FC = (lang: Language) => ( +
  • + {/* Language name, and native name if applicable */} + {lang.name}{lang.nativeName && ({lang.nativeName})} + + {/* List of contributors */} + {lang.contributors && lang.contributors.map(({ url, name }) => + )} +
  • +); export class TranslatorsComponent extends Component { render(): ReactNode { @@ -23,9 +47,9 @@ const translateURL = packageJson.translateURL; if (!translateURL) return null; - // Get the translator information from translators.json - if (!req.keys().includes("./translators.json")) return null; - const translators: { [key: string]: Translator[] } = req("./translators.json"); + // Get the translator information from languages.json + if (!req.keys().includes("./languages.json")) return null; + const languages: { [key: string]: Language } = req("./languages.json"); return <> @@ -34,20 +58,12 @@

    {t("credits.translatorsDescription")}

    - {/* Translator list */} + {/* Language list */}
      - {Object.entries(translators).map(([language, people]) => -
    • - {language} - - {people.map(({ url, name }: Translator) => - url - ? {name} - : {name} - )} -
    • - )} + {Object.entries(languages) + .filter(([code, lang]) => code !== "en" && lang.contributors && lang.contributors.length > 0) + .map(([code, lang]) => )}
    diff --git a/translators.json b/translators.json deleted file mode 100644 index 34a8ca3..0000000 --- a/translators.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "German (Deutsch)": [ - { - "name": "Lignum", - "url": "https://github.com/Lignum" - } - ], - "Vietnamese (Tiếng Việt)": [ - { - "name": "Boom", - "url": "https://github.com/signalhunter" - } - ], - "French (Français)": [ - { - "name": "Anavrins", - "url": "https://github.com/xAnavrins" - } - ] -}