UNPKG

@instructure/canvas-rce

Version:

A component wrapping Canvas's usage of Tinymce

33 lines (25 loc) 2.26 kB
# I18n ## Overview Each locale has two I18n files that are needed: A Canvas-managed JSON file that contains translations for our custom text, and a Tiny-managed JavaScript file for native TinyMCE menus and content: ### Canvas-manged JSON I18n files - Live in `canvas-lms/packages/translations/lib/canvas-rce` - Added to `formatMessage` via `formatMessage.addLocale({<locale code>: <translation keys/values>})` ### Tiny-managed JavaScript Translation files - Manually pulled down from [this page](https://www.tiny.cloud/get-tiny/language-packages) - Live in `canvas-rce/src/translations/tinymce` - Added to `tinymce.I18n` via `tinymce.addI18n(<locale code>, <translation keys/values>` ## Building Rather than import these two files into RCE individually, canvas-rce has some build tooling to copy the Canvas-managed translations over to JavaScript files (located in `canvas-rce/src/translations/locales`) and then mix in the Tiny-managed translations (via an `import`). In the end, this results in a single JavaScript file per locale that can be imported into RCE. To handle importing the correct "combined" locale file, the build tooling also generates a helper function called `getTranslations()` (located at `canvas-rce/src/getTranslations.js`) The "combined" locale files live in `canvas-rce/src/translations/locales` For more details on the build process see `canvas-rce/scripts/installTranslations.js` ## Adding new Locales Adding a new locale takes a few steps to ensure things work with the I18n build tooling and runtime importing. 1. Download the new Locale from [this page](https://www.tiny.cloud/get-tiny/language-packages) 2. Unzip the language pack and move the locale .js file to `canvas-rce/src/translations/tinymce` 3. Add the new locale to the mapping of Canvas locale codes to TinyMCE locale codes in `canvas-rce/src/rce/editorLanguage.js` 4. Add the new locale to the `recognized` array in `canvas-rce/src/rce/normalizeLocale.js` 5. Run `yarn installTranslations` to generate the "combined" locale file 6. `git add` the new Tiny-managed locale file added in step 2 7. `git add` the new generated "combined" locale file found in `canvas-rce/src/translations/locales` 8. `git add` the rest of the modified files, commit, and push \o/