Wrap your app in the TranslationProvider component to enable Lexicon within your app.
<TranslationProvider />
is required to use Lexicon’s translation features. You must include it at the top of your component tree as a wrapper - as mentioned in our quick start guide.
You should only import this one time at the top of your application to enable translations.
PUBLISHABLE_KEY
with the key you found in your dashboard.
en-US
translations
).You would simply import your translation file into your component and feed the JSON into this prop.Please see how to generate translations for details on generating this file.es-ES
Use formal language
defaultLanguage
field and determine whether something needs to be translated.We do this so that you don’t waste translation credits translating “English” into another dialect of “English”.If you set this to false, we will translate even when the language is the same if the country/dialect is different. This could be useful in some languages if there are major differences in dialects.translationFile
for a translation that matches the targetLanguage
we’re translating to, this determines whether or not we should attempt to fallback to a matching entry with the same base language when we can’t find an entry for the entire locale (including country code).We usually recommend leaving this as true
to save on translation credits and reduce queries unless you expect some nuances in the dialects between your users’ countries and want to be as accurate as possible.For example, if this is left as true
and we are trying to translate to “es-ES” [Spanish Spain], but we only have a translation file that contains the correct translations for “es” [Spanish], then we will simply use the “es” translations for this user (ignoring the country code and falling back to the more generic base language). If you set this to false
, we would instead generate a fresh translation for “es-ES” and then cache it on the user’s device.