kamilmielnik / scrabble-solver

Free, open-source, cross-platform, and multi-language analysis tool for Scrabble, Super Scrabble & Literaki. Quickly find top scoring words using given board & tiles. Available in English, French, German, Persian, Polish, Romanian & Spanish.
https://scrabble-solver.org
Other
92 stars 20 forks source link

Simplify & document how to add a new language #300

Closed kamilmielnik closed 1 year ago

kamilmielnik commented 1 year ago

Locale flag

  1. Find and download a flag representing the locale in an SVG format
  2. Rename the flag to FlagXX.svg and put it in packages/scrabble-solver/src/icons
  3. Export the SVG file in packages/scrabble-solver/src/icons/index.ts
  4. Add --flag--xx--aspect-ratio variable in packages/scrabble-solver/src/styles/variables.scss
  5. Reference that aspect ratio variable in packages/scrabble-solver/src/i18n/i18n.module.scss

Language features

  1. Add IETF language tag for the new locale in packages/types/src/Locale.ts
    • Rebuild the types package after this step
      npx lerna run build --scope=@scrabble-solver/types
  2. Update packages/scrabble-solver/src/i18n/constants.ts

Game configs

  1. Add game configs for the new locale in in packages/configs/src/locales
  2. Add an export for this locale in packages/configs/src/locales/index.ts

Translations

  1. Add a translation file called xx.json in packages/scrabble-solver/src/i18n and fill it with translations.
    • It's easier to copy an existing file, e.g. en.json and modify it
  2. Add an entry for the translations in packages/scrabble-solver/src/i18n/i18n.ts

Word list

  1. Add a function to fetch the list of words in the new locale in packages/word-lists/src/getWordList.ts

Word definitions

  1. Add a function to fetch the word definition in the new locale in packages/word-definitions/src/crawl/crawl.ts
  2. Add a function to parse the word definition crawled in step 3 in packages/word-definitions/src/parse/parse.ts