Skip to content

Adds support for internationalization and updates configuration files.#388

Open
danfmsouza wants to merge 3 commits into
ThaumRystra:developfrom
danfmsouza:feature-i18n
Open

Adds support for internationalization and updates configuration files.#388
danfmsouza wants to merge 3 commits into
ThaumRystra:developfrom
danfmsouza:feature-i18n

Conversation

@danfmsouza
Copy link
Copy Markdown

@danfmsouza danfmsouza commented Feb 22, 2025

Vue I18n Implementation

As asked by @GyufiThePenguin in the issue #351 (now is a feature request). I tried to implement a simple UI internationalization. It still no t affecting .ts files, but the interface was almost 90% translated.

The internationalization was implemented using Vue I18n in the following steps:

1. Initial Setup

  • Added VueI18n configuration in the i18n.js file
  • Imported locale files from the locales directory

2. Language Detection Created a detectBrowserLocale() function that:

  • Gets available locales from messages
  • Detects browser language
  • Falls back to 'en' if browser language is not supported

3. Locale Configuration Set up supported languages:

messages: {
  'en': messages.en, // Default
  'pt': messages.pt, 
  'es': messages.es,
  'fr': messages.fr
}

4. Translation Structure

  • Created JSON files for each language in the locales directory
  • Organized translations using nested objects with unique keys
  • Set up en_US.json as the base translation file

5. Integration

  • Added Vue I18n script in head.html
  • Set up locale imports in index.js
  • Configured fallback locale as 'en' for missing translations

This implementation allows the application to:

  • Automatically detect user's browser language
  • Support multiple languages (EN, PT, ES, FR)
  • Fallback to English when a translation is missing
  • Maintain organized translation files per language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant