The purpose of this package is to maintain the common reusable translations which can be consumed across the µ-apps.
Translations are split into multiple folders to facilitate lazy loading with i18next's namespaces. Each folder must have it's own purpose in the context of it's usage.
!!! info Translation keys must be generic and not include any app/module name as prefix/suffix as the content from this package will be made available for all the µ-apps.
- Create a new folder in
packages/manager/modules/common-translations/public/translations
- Add
Messages_fr_FR.json
file. - Add all the required translations with appropriate keys.
- Follow the usual translation process of Submitting a request to CMT team and then Retrieving the translations to make the corresponding changes in other locale files.
- Add/Update the required content with appropriate keys in
Messages_fr_FR.json
file. - Follow the usual translation process of Submitting a request to CMT team and then Retrieving the translations to make the corresponding changes in other locale files.
The "@ovh-ux/manager-common-translations" package provides the following,
- Content for all the supported locales.
- A
NAMESPACES
constant to facilitate easy loading of i18next's namespace.
To consume the translations provided by the package,
-
You need to include the package as dependency in your µ-app or other package where you intend to consume it.
{ ... ... "dependencies": { "@ovh-ux/manager-common-translations": "x.x.x", ... ... } }
-
In your React component, you can consume the translations from the package as shown in the below code-snippet.
import { useTranslation } from 'react-i18next'; import { NAMESPACES } from '@ovh-ux/manager-common-translations'; export const ReactComponent = () => { ... const { t } = useTranslation(NAMESPACES.<NAMESPACE_NAME>); ... return ( ... <>{{t('<TRANSLATION_KEY>')}}</> ... ); }
!!! warning @ovh-ux/manager-vite-config automatically includes the translation files in the final bundle of the µ-app. If the base config provided by this package is not consumed in your µ-app, it will be your responsibility to add these files in your bundle.