Interpolation allows dynamic values to be used within translations.
In the JSON file, we use {{ }} brackets to indicate where we will be using interpolation. This value will change depending on our provided value in the translation hook.
Code Block |
---|
user_pet: "I have a pet {{animal}}" |
Our code where the translation key is rendered:
Code Block |
---|
t('user_pet', {animal: "cat"}) |
The code will now appear as:
Code Block |
---|
"I have a pet cat" |