BREAKING - Reworked translation system:
tr()
, tr.setLanguage()
and tr.getLanguage()
tr.addLanguage()
to tr.addTranslations()
%n
-based argument insertion by default (re-enable explicitly with tr.addTransform(tr.transforms.percent)
).tr.for()
- translates a key for the specified language.tr.use()
- creates a translation function for the specified language for much easier usage.tr.hasKey()
- checks if a key exists in the given language.tr.setFallbackLanguage()
- sets the fallback language used when a key is not found in the given language.tr.getFallbackLanguage()
- returns the fallback language.tr.addTransform()
- adds a transform function to the translation system, allowing for custom argument insertion and much more.tr.deleteTransform()
- removes a transform function.${keyName}
) with tr.addTransform(tr.transforms.templateLiteral)
. This transform supports positional argument injection, as well as named arguments via an object with the same keys as in the template literal pattern. See the documentation for more information and a code example.TrKeys<T>
for extracting the keys of a translation object (both flat and nested).