You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function returns the translation of the passed key in the language added by [`tr.addLanguage()`](#traddlanguage) and set by [`tr.setLanguage()`](#trsetlanguage)
2254
-
Should the translation contain placeholders in the format `%n`, where `n` is the number of the value starting at 1, they will be replaced with the respective item of the `values` rest parameter.
2255
-
The items of the `values` rest parameter will be stringified using `toString()` (see [Stringifiable](#stringifiable)) before being inserted into the translation.
2254
+
Should the translation contain placeholders in the format `%n`, where `n` is the number of the value starting at 1, they will be replaced with the respective item of the `insertValues` rest parameter.
2255
+
The items of the `insertValues` rest parameter will be stringified using `toString()` (see [Stringifiable](#stringifiable)) before being inserted into the translation.
2256
2256
2257
2257
Should you be using nested objects in your translations, you can use the dot notation to access them.
2258
2258
First, the key will be split by dots and the parts will be used to traverse the translation object.
2259
2259
If that doesn't yield a result, the function will try to access the key including dots on the top level of the translation object.
2260
2260
If that also doesn't yield a result, the key itself will be returned.
2261
2261
2262
-
If no language has been added or set before calling this function, it will return the key itself.
2262
+
If no language has been added or set before calling this function, it will also return the key itself.
2263
+
2264
+
To check if a translation has been found, compare the returned value with the key. If they are the same, the translation was not found.
2265
+
You could also write a wrapper function that can then return a default value or `null` if the translation was not found instead.
2266
+
2263
2267
If the key is found and the translation contains placeholders but none or an insufficient amount of values are passed, it will try to insert as many values as were passed and leave the rest of the placeholders untouched in their `%n` format.
2264
2268
If the key is found, the translation doesn't contain placeholders but values are still passed, the values will be ignored and the translation will be returned without modification.
0 commit comments