Internationalization
FishtVue provides comprehensive multilingual support for UI components, enabling seamless translation and localization of interfaces with flexible language pack integration.
Installation and Locale Setup
To enable localization in FishtVue, you must configure it during the library installation (usually in main.ts or main.js):
Required Fields in Locale Config
| Field | Description |
|---|---|
defaultLocale | The default language code (e.g., 'en', 'ru') |
activeLocale | The currently active language |
locales | An array of locale metadata (name + code) |
messages | A dictionary of translations per locale code |
Types Reference
FishtVue uses several internal types for localization:
You can provide only the messages you need — the rest will be ignored.
Using Locale Methods at Runtime
You can access and update the current locale using methods exposed by the global FishtVue instance.
Inject the instance like this:
Method Overview
| Method | Description |
|---|---|
getActiveLocale() | Returns the currently active locale code |
setActiveLocale(code) | Updates the active locale dynamically |
getDefaultLocale() | Returns the default locale code |
How Components Use Translations
Every FishtVue component has access to the t() method for translating keys.
It looks up the current active locale and finds the translation from messages.
Notes:
- Keys can be nested:
t('pagination.next') - If the key is missing, it returns
undefined - If the translation is not a string, it’s ignored
Best Practices
- Always define at least a minimal set of messages for each language you support.
- Use consistent keys (e.g.,
pagination.next,buttons.save) to keep your messages structured. - Use
setActiveLocale()to change language on the fly (e.g., from a language selector). - You can add new locale messages dynamically by updating
FishtVue.config.locale.messages.
Language Switcher
For example, the Language Switcher component allows users to select their preferred language from a dropdown menu, dynamically updating the language of the UI.