Providing Context

Sometimes you need additional control over your translations to get the desired output.

This is most obvious when you are translating singular words that lack the context of sentences.

For example, you could interpret the word “Save” in two ways:

  1. To keep safe or rescue
  2. To keep and store up

To address this, we allow you to provide context to various components and hooks within the Lexicon ecosystem.

In the “Save” example above, you could do the following to indicate that you are referring to banking…

<TranslatedText context="Save money">Save</Text>

Overall Translation Guidance

You can also provide guidance to the model as a whole by providing the translationGuidance prop to the <TranslationProvider /> component.

This allows you to tweak translations across your entire app if you want to change something.

For example, if you wanted your translations to sound more formal and less casual, you could provide the following guidance…

<TranslationProvider
  defaultLanguage="en-US" 
  token={PUBLISHABLE_KEY}
  translationGuidance="Use formal language">
  <App />
</TranslationProvider>