Quick Start
Start translating your app into every language in under 5 minutes.
This quick start guide will get you up and running with Lexicon.
Create a Lexicon account
Go to app.lexiconjs.com and create a free account.
Get your publishable key
Grab your publishable key from your dashboard’s API Keys tab and save it for later.
Install the @lexiconjs/react module
Add the @lexiconjs/react package to your existing project.
In a terminal window run:
Install and configure the react-native-mmkv module (only for React Native)
If your app is using React Native, you will also need to add the react-native-mmkv package to your existing project and ensure it’s properly linked using one of the instruction sets below (Expo or React Native).
We use this package to ensure caching is as fast as possible on mobile devices. You can review their docs for more details.
React Native
In a terminal window run:
Expo
In a terminal window run:
Note: If you are using expo, you will need to use the expo-dev-client in order to run @lexiconjs/react locally.
Wrap your app in <TranslationProvider />
The <TranslationProvider />
component enables the automatic translation of your app’s text inside of other components. Import it into your codebase by adding import { TranslationProvider } from "@lexiconjs/react"
at the top of your entry file and then wrap your app with it.
Make sure to replace the PUBLISHABLE_KEY
with the key you found in your dashboard.
Use Lexicon components to translate your app
The simplest way to translate text is to simply wrap some text with the <TranslatedText />
component. It will detect the user’s locale via their device settings and generate a translation in real time. Afterward, it stores the translation in a local cache to ensure everything stays as fast as possible.
We recommend extending the <Text />
component from whatever component library you’re using into a custom component so that you don’t need to include <TranslatedText />
everywhere.
See the TranslatedText documentation for more details.