Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 2.17 KB

File metadata and controls

70 lines (50 loc) · 2.17 KB

Localization

Supported locales

The editor supports the following locale codes:

Code Language Role
en Neutral English Default and fallback locale.
es Neutral Spanish User-selectable locale.
pt Neutral Portuguese User-selectable locale.

Locale catalogs are stored in locales/<code>.json. Every catalog must expose the same keys under the strings object.

Runtime behavior

The language selector is located in the application header. A locale change is applied without reloading the page and is persisted under the local-storage key mapbuilder.locale. A new browser profile starts in English regardless of the browser language.

The runtime loads locale files through repository-relative HTTP requests. If a stored non-English locale cannot be loaded, the editor retries with English.

Translation keys

English source text is the translation key. Static DOM text and translatable attributes are resolved against the active catalog. Dynamic messages call the t function directly and may provide named interpolation values:

t("{count} tiles connected.", { count: formatNumber(reached) });

Placeholders use braces and must remain identical across locales. Do not translate technical identifiers, keyboard keys, file extensions, item names, or monster names.

Adding a locale

  1. Copy locales/en.json to locales/<code>.json.
  2. Translate every value without changing its key.
  3. Add the locale code to SUPPORTED_LOCALES.
  4. Add a native-language option to #language-select.
  5. Confirm that all catalogs have identical key sets.
  6. Test static text, dynamic messages, dialogs, accessibility labels, and persistence after reload.

Validation

Run JSON syntax validation for every catalog:

for file in locales/*.json; do jq empty "$file"; done

Confirm key parity against the English catalog:

for file in locales/*.json; do
  echo "$file"
  diff <(jq -r '.strings | keys[]' locales/en.json) <(jq -r '.strings | keys[]' "$file")
done

Locale changes must also confirm that English remains the default when no saved preference exists, and that a locale switch leaves no untranslated node in the document.