The OpenBMC Web UI implements internationalization and separates the language- specific parts of the interface from the rest of the code, so they can be easily replaced. The OpenBMC Web UI uses the following library for internationalization:
The OpenBMC Web UI follows the following key naming conventions:
page
followed by the page title. Formatting in this manner provides a systematic structure and improves readability of the language file.pageLocalUserManagement.editUser
pageEventLogs.table.eventType
$t()
function in markup and this.$t
in scripts (which Vue I18n provides to our components) for outputting translation messages.src/i18n.js
file is added and it registers Vue I18n as a plugin to our Vue instance via the Vue.use()
function.src/locales/en-US.json
file, which contains our default translation messages.src/locales/en-US.json
file and then the $t()
function is used to output the translation messages.$t
please run this to ensure consistent English translation (note: using variable expansion in key names is not handled automatically, you need to manually check them):node node_modules/vue-i18n-extract/bin/vue-i18n-extract.js -v 'src/**/*.?(js|vue)' -l 'src/locales/en-US.json'
node node_modules/vue-i18n-extract/bin/vue-i18n-extract.js -v 'src/**/*.?(js|vue)' -l 'src/locales/ru-RU.json' -a
"pageDumps": { "dumpsAvailableOnBmc": "Dumps available on BMC" }
<page-section :section-title="$t('pageDumps.dumpsAvailableOnBmc')">
$tc()
function can help with displaying plurals. Learn more about pluralization."modal": { "deleteDump": "Delete dump | Delete dumps" }
this.$bvModal .msgBoxConfirm(this.$tc('pageDumps.modal.deleteDumpConfirmation'), { title: this.$tc('pageDumps.modal.deleteDump'), okTitle: this.$tc('pageDumps.modal.deleteDump'), cancelTitle: this.$t('global.action.cancel'), autoFocusButton: 'ok', })
To keep the base translation files vendor-neutral, vendor-specific strings live under src/env/locales/<envName>/
.
src/env/locales/vendor/
)src/env/locales/vendor-variant/
)src/locales/
(auto-discovered)src/env/locales/vendor/
)src/env/locales/vendor-variant/
)Notes:
src/locales/
are bundled automatically.src/env/locales/
that match the active environment are also bundled.Example: moving vendor-only dump type labels
// src/locales/en-US.json (base) { "pageDumps": { "dumpTypes": {} } } // src/env/locales/nvidia/en-US.json (overlay) { "pageDumps": { "dumpTypes": { "hmcDump": "HMC dump", "bmcDump": "BMC dump", "systemBmcDump": "System [BMC] dump (disruptive)", "systemHgxDump": "System [HGX] dump (disruptive)" } } }
We support aliasing short codes to our canonical locales:
en
→ en-US
ru
→ ru-RU
zh
→ zh-CN
ka
→ ka-GE
If a short code is stored (e.g., in localStorage), it will be normalized at app startup.