Dictionaries
How to use dictionaries
Overview
As an alternative to the <T>
component, dictionaries are a way to translate content in General Translation.
Contrary to to the <T>
component, dictionaries store all translations in a single file, in a key-value format.
There are a few advantages to using dictionaries over the <T>
component:
- Centralized Storage: Dictionaries store all translatable content in a single file, making it easier to manage and update.
- Historical Precedent: The dictionary pattern is a common design pattern in the industry and is used by many other libraries.
At the same time, it has some disadvantages as well:
- Complexity: Dictionaries are more complex to set up and use than the
<T>
component. - Readability: Dictionaries are less readable than the
<T>
component because the content is not inline.
Both design patterns are supported by our library and are not mutually exclusive.
You can use a dictionary alongside <T>
components.
Here is an example of a dictionary:
Here's how you would use the dictionary in a component:
To learn more, see the specific reference for the corresponding framework: