From 59886b2fc603d0cb9ac324b8b7877db600f039ec Mon Sep 17 00:00:00 2001 From: Kamil Mielnik Date: Sun, 11 Feb 2024 03:18:16 +0700 Subject: [PATCH] Refactor languages in i18n --- README.md | 2 +- .../src/i18n/{en.json => english.json} | 0 .../src/i18n/{fr.json => french.json} | 0 .../src/i18n/{de.json => german.json} | 0 packages/scrabble-solver/src/i18n/i18n.ts | 30 +++++++++---------- .../src/i18n/{fa.json => persian.json} | 0 .../src/i18n/{pl.json => polish.json} | 0 .../src/i18n/{ro.json => romanian.json} | 0 .../src/i18n/{es.json => spanish.json} | 0 9 files changed, 16 insertions(+), 16 deletions(-) rename packages/scrabble-solver/src/i18n/{en.json => english.json} (100%) rename packages/scrabble-solver/src/i18n/{fr.json => french.json} (100%) rename packages/scrabble-solver/src/i18n/{de.json => german.json} (100%) rename packages/scrabble-solver/src/i18n/{fa.json => persian.json} (100%) rename packages/scrabble-solver/src/i18n/{pl.json => polish.json} (100%) rename packages/scrabble-solver/src/i18n/{ro.json => romanian.json} (100%) rename packages/scrabble-solver/src/i18n/{es.json => spanish.json} (100%) diff --git a/README.md b/README.md index dd5a8da9..ddc9a611 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ npm run build -w @scrabble-solver/PACKAGE_NAME 8. Add game configs for the new locale in [packages/configs/src/languages](https://github.com/kamilmielnik/scrabble-solver/blob/master/packages/configs/src/languages) 9. Add an export for these locale configs in [packages/configs/src/languages/index.ts](https://github.com/kamilmielnik/scrabble-solver/blob/master/packages/configs/src/languages/index.ts) 10. Add a translation file in [packages/scrabble-solver/src/i18n](https://github.com/kamilmielnik/scrabble-solver/tree/master/packages/scrabble-solver/src/i18n) and fill it with translations - - Copy any existing file, e.g. `en.json` and modify it + - Copy any existing file, e.g. `english.json` and modify it 11. Add an entry for the translations in [packages/scrabble-solver/src/i18n/i18n.ts](https://github.com/kamilmielnik/scrabble-solver/tree/master/packages/scrabble-solver/src/i18n/i18n.ts) 12. Add a function to fetch the list of words in the new locale in [packages/word-lists/src/getWordList.ts](https://github.com/kamilmielnik/scrabble-solver/blob/master/packages/word-lists/src/getWordList.ts) 13. Add a function to fetch the word definition in the new locale in [packages/word-definitions/src/crawl.ts](https://github.com/kamilmielnik/scrabble-solver/blob/master/packages/word-definitions/src/crawl.ts) diff --git a/packages/scrabble-solver/src/i18n/en.json b/packages/scrabble-solver/src/i18n/english.json similarity index 100% rename from packages/scrabble-solver/src/i18n/en.json rename to packages/scrabble-solver/src/i18n/english.json diff --git a/packages/scrabble-solver/src/i18n/fr.json b/packages/scrabble-solver/src/i18n/french.json similarity index 100% rename from packages/scrabble-solver/src/i18n/fr.json rename to packages/scrabble-solver/src/i18n/french.json diff --git a/packages/scrabble-solver/src/i18n/de.json b/packages/scrabble-solver/src/i18n/german.json similarity index 100% rename from packages/scrabble-solver/src/i18n/de.json rename to packages/scrabble-solver/src/i18n/german.json diff --git a/packages/scrabble-solver/src/i18n/i18n.ts b/packages/scrabble-solver/src/i18n/i18n.ts index efa0b118..0ffcbeff 100644 --- a/packages/scrabble-solver/src/i18n/i18n.ts +++ b/packages/scrabble-solver/src/i18n/i18n.ts @@ -2,23 +2,23 @@ import { Locale } from '@scrabble-solver/types'; import { Translations } from 'types'; -import de from './de.json'; -import en from './en.json'; -import es from './es.json'; -import fa from './fa.json'; -import fr from './fr.json'; -import pl from './pl.json'; -import ro from './ro.json'; +import english from './english.json'; +import french from './french.json'; +import german from './german.json'; +import persian from './persian.json'; +import polish from './polish.json'; +import romanian from './romanian.json'; +import spanish from './spanish.json'; const i18n: Record = { - [Locale.DE_DE]: de, - [Locale.EN_GB]: en, - [Locale.EN_US]: en, - [Locale.ES_ES]: es, - [Locale.FA_IR]: fa, - [Locale.FR_FR]: fr, - [Locale.PL_PL]: pl, - [Locale.RO_RO]: ro, + [Locale.DE_DE]: german, + [Locale.EN_GB]: english, + [Locale.EN_US]: english, + [Locale.ES_ES]: spanish, + [Locale.FA_IR]: persian, + [Locale.FR_FR]: french, + [Locale.PL_PL]: polish, + [Locale.RO_RO]: romanian, }; export default i18n; diff --git a/packages/scrabble-solver/src/i18n/fa.json b/packages/scrabble-solver/src/i18n/persian.json similarity index 100% rename from packages/scrabble-solver/src/i18n/fa.json rename to packages/scrabble-solver/src/i18n/persian.json diff --git a/packages/scrabble-solver/src/i18n/pl.json b/packages/scrabble-solver/src/i18n/polish.json similarity index 100% rename from packages/scrabble-solver/src/i18n/pl.json rename to packages/scrabble-solver/src/i18n/polish.json diff --git a/packages/scrabble-solver/src/i18n/ro.json b/packages/scrabble-solver/src/i18n/romanian.json similarity index 100% rename from packages/scrabble-solver/src/i18n/ro.json rename to packages/scrabble-solver/src/i18n/romanian.json diff --git a/packages/scrabble-solver/src/i18n/es.json b/packages/scrabble-solver/src/i18n/spanish.json similarity index 100% rename from packages/scrabble-solver/src/i18n/es.json rename to packages/scrabble-solver/src/i18n/spanish.json