Skip to main content

Localization

  • useSafeTranslation hook

    • Pass in the "namespace" as the parameter  image.png

  • Define string lookup keys as enums

    • Need to be single strings with no spaces

  

  • Use the "t" method

    • If the key doesn't exist it will be added

    • Must run the code and navigate to location




  • locales folder contains all the string translations

    • Namespace matches the name of the json file

  

  • If rendering of page needs to wait for the json file to be loaded in use the ready value from useSafeTranslation, around the return value. (May need if page doesn't load and you get white screen)

image.png

image.png

Plurals

see i18n documentation here. Plurals are useful when the copy needs to change slightly when you have multiple items, for example, when you are deleting 2 items instead of one, you want to add an 's' to the end of a word to make it plural.

Nesting

see i18n documentation here. Nesting is useful when you need pass multiple values into the copy, for example, when you the copy indicates how many file uploads and form fills are in a document request that is assigned to you.