1# Internationalization 2 3The OpenBMC Web UI implements internationalization and separates the language- 4specific parts of the interface from the rest of the code, so they can be easily 5replaced. The OpenBMC Web UI uses the following library for 6internationalization: 7 8- [Vue I18n](https://kazupon.github.io/vue-i18n/introduction.html) 9 10## Key naming convention 11 12The OpenBMC Web UI follows the following key naming conventions: 13 14- Page specific labels should be nested in an object with a key prefixed `page` 15 followed by the page title. Formatting in this manner provides a systematic 16 structure and improves readability of the language file. 17 - e.g. `pageLocalUserManagement.editUser` 18- Any 'major' child components should be nested inside page specific objects 19 (ex. table, modal) 20 - e.g. `pageEventLogs.table.eventType` 21- Avoid any complex linked locale messages. 22- Alphabetize object keys. This helps in locating the keys. 23- We use the `$t()` function in markup and `this.$t` in scripts (which Vue I18n 24 provides to our components) for outputting translation messages. 25 26## Using the Vue I18n plugin 27 28- A new `src/i18n.js` file is added and it registers Vue I18n as a plugin to our 29 Vue instance via the `Vue.use()` function. 30- The CLI creates a `src/locales/en-US.json` file, which contains our default 31 translation messages. 32- The keys are placed in the `src/locales/en-US.json` file and then the `$t()` 33 function is used to output the translation messages. 34- After adding or removing calls to `$t` please run this to ensure consistent 35 English translation (note: using variable expansion in key names is not 36 handled automatically, you need to manually check them): 37 38```bash 39node node_modules/vue-i18n-extract/bin/vue-i18n-extract.js -v 'src/**/*.?(js|vue)' -l 'src/locales/en-US.json' 40``` 41 42- If you're working on updating a translation for another language (e.g. 43 Russian), run this to see the omissions (as well as cruft) and add the 44 necessary keys automatically: 45 46```bash 47node node_modules/vue-i18n-extract/bin/vue-i18n-extract.js -v 'src/**/*.?(js|vue)' -l 'src/locales/ru-RU.json' -a 48``` 49 50```json 51"pageDumps": { 52 "dumpsAvailableOnBmc": "Dumps available on BMC" 53} 54``` 55 56```Vue 57<page-section :section-title="$t('pageDumps.dumpsAvailableOnBmc')"> 58``` 59 60- Vue I18n’s `$tc()` function can help with displaying plurals. 61 [Learn more about pluralization.](https://kazupon.github.io/vue-i18n/guide/pluralization.html) 62 63```json 64"modal": { 65 "deleteDump": "Delete dump | Delete dumps" 66} 67``` 68 69```JS 70this.$bvModal 71 .msgBoxConfirm(this.$tc('pageDumps.modal.deleteDumpConfirmation'), { 72 title: this.$tc('pageDumps.modal.deleteDump'), 73 okTitle: this.$tc('pageDumps.modal.deleteDump'), 74 cancelTitle: this.$t('global.action.cancel'), 75 }) 76``` 77