The Node.js® Website
1# Node.js Website Translation Policy 2 3Node.js is a global platform and so this site has many translations. We use [Crowdin](https://crowdin.com) to translate the Node.js Website 4 5The site's translation into languages other than English is handled by [Crowdin translators](https://support.crowdin.com/translation-process-overview/). 6 7We use [`next-intl`](https://next-intl-docs.vercel.app/) as our Internationalization Library. We recommend reading its documentation for API usage. 8 9## How to translate 10 111. Request to join the Node.js Website project on [Crowdin](https://crowdin.com/project/nodejs-web) 122. [Select the language you want to translate](https://support.crowdin.com/joining-translation-project/#starting-translation) 133. [Start translating](https://support.crowdin.com/online-editor/) 14 15### Any questions or feedbacks on Translations 16 17If you have any questions or feedbacks on current translations, you can [start a discussion](https://crowdin.com/project/nodejs-web/discussions) by choosing the "New Topic" and your language from the right dropdown, or a [conversation](https://support.crowdin.com/conversations/) by adding your translators. 18 19## How to add a new language 20 21Open discussion on the [Crowdin project](https://crowdin.com/project/nodejs-web) to request a new language. After wait for the language to be added to the project by the Crowdin manager 22 23After that, one of the member of the Node.js Website team should add the new language to the project. 24 25### Adding a new language to the project 26 27Go on `/i18n/config.json` and add the new language to the `locales` array. 28 29Fill the language object with the following fields: 30 31```json 32{ 33 "code": "fr", 34 "localName": "Français", 35 "name": "French", 36 "langDir": "ltr", 37 "dateFormat": "DD.MM.YYYY", 38 "hrefLang": "fr", 39 "enabled": true 40} 41``` 42 43| Field Name | Description | Examples | 44| ------------ | ------------------------------------------------------------------------------------------------------ | ------------ | 45| `code` | The language code. It must be the same as the folder name | `fr` | 46| `localName` | The language name in its own language (it's use in language selector) | `Français` | 47| `name` | The language name in English | `French` | 48| `langDir` | The direction of the language. `ltr` for left to right, `rtl` for right to left | `ltr` | 49| `dateFormat` | The date format. It must be a valid [moment.js format](https://momentjs.com/docs/#/displaying/format/) | `DD.MM.YYYY` | 50| `hrefLang` | The language code in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format | `fr` | 51| `enabled` | If the language is enabled or not | `true` | 52 53## Adding new Translation Keys 54 55If you're making a new Component and adding Translation Keys for your Component, they should follow these guidelines: 56 57- Only add the new translation keys on the `i18n/locales/en.json` file. Crowdin will handle on syncing the files and letting translators know there are new keys to be translated 58- The translation keys should have the prefix as the canonical path of your Component. If your Component is `components/Common/MyComponent` the prefix key should be `components.common.myComponent` 59 - The Translation Key suffix should be easy to understand and semantic. For example, if the key is about "the text of a button that when interacted it copies content to the clipboard", the suffix should probably be `copyButton.title`. The final translation key would be `components.common.myComponent.copyButton.title` 60 - Translation Keys should be in Camel Case only. 61 - The values of each Translation Key should follow the [ICU Message Syntax](https://next-intl-docs.vercel.app/docs/usage/messages#rendering-icu-messages) 62- All new Translation keys should be added at the bottom of the `i18n/locales/en.json` file. Since this makes it easier for Translators to notice that there are new Translation keys to be translated. 63 64#### Notes about Translation Keys 65 66It's important to mention that we use nested translation keys within the Locale files. This means that if your translation key is `components.common.myComponent.something`, you should actually define the key and value within: 67 68```json 69{ 70 "components": { 71 ..., 72 "common": { 73 ..., 74 "myComponent": { 75 "something": "value of translation key" 76 } 77 } 78 } 79} 80``` 81 82### Translations and Unit Testing 83 84Translation Keys should not be translated during Unit Testing. If your Component uses, for example `useTranslations`, you should provide the `<NextIntlProvider>` surrounding your `testing-library` render logic, or you can create a wrapper for your test. Note that you should not import the English messages to your Unit Test as: 85 86- Unit Testing should test a Component functionality. 87- Unit Tests should not rely on text, titles, or string bags, as these texts will change arbitrarily and make the test suite fail. 88 - In this case, you should test your component by aria-text, or other `aria-*` attributes or even by class names or other artifacts. 89- Visual Regression Testing is recommended to test how different languages and text appear within a Component.