Skip to main content

Localize your React App the simplest way you've ever seen

ยท 5 min read

Translating an App to multiple languages (localization) is tricky part of many applications. Tolgee is simplifying the localization process and saves developer's time by removing repetitive tasks ๐Ÿ” โŒ.

In this article, we'll explore how Tolgee offers a streamlined solution for React localization, empowering developers to efficiently translate and adapt their applications for diverse audiences. From simplifying text translation to providing in-context editing features, Tolgee revolutionizes the localization experience for React developers.

Saving time? That's what I want. Show me how to localize my React app!

What is Tolgee?โ€‹

Tolgee is an open-source i18n tool combining a localization platform and SDKs to provide a simple way to translate web applications for both developers and translators. ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป๐Ÿง–๐Ÿผ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป๐Ÿง–๐Ÿผ Tolgee is not just another software localization platform offering integrations that only syncs local data with the backend. Instead, Tolgee is truly integrated into your app via SDKs. So, no more looking for keys in your source code, no more editing localization files, and no more data exporting for translators.

In-context translatingโ€‹

As a developer of localized application, you probably have to modify localization data every time you need to change a text. So you have to open the file, add or find the key to modify it, save it and check whether everything was changed correctly in the app. With Tolgee, you can just ALT + click the actual translated text in your app, and ๐Ÿ’ฅboom๐Ÿ’ฅ translation dialog appears, and you are able to translate it right away. You can even translate in-context on production.

Tolgee - in context translation dialog

Automatic Screenshot Generation ๐Ÿ“ธโ€‹

Another tricky part of software localization is providing context ๐Ÿ“– to translators. Only exporting the keys and translations in the source language is not always enough. Tolgee enables you to take and upload screenshot directly in the in-context translation dialog. So no more manual taking and uploading screenshots.๐ŸŒ„

Localization platform included โœ…โ€‹

Tolgee is also a localization platform where you can manage all your localization strings ๐Ÿ“š. So you can provide access to translators, and they can translate the texts there. If you have uploaded screenshots before, they know the context of the translations perfectly, so they can produce perfect results. You can watch a short tour in the Tolgee platform on our YouTube Channel.

Isn't that hard to integrate? No, it's not!โ€‹

To get started localizing your React app, you can simply follow the integration guides provided in the Tolgee localization platform, which is the simplest way to start.

  1. Login to Tolgee Cloud or use your self-hosted Tolgee instance.

  2. Create a new project by clicking the Add button in the top right. And filling in the project name.

    Add button

    Optionally, you can add multiple languages to translate your React app into.

  3. Select Integrate from the side menu, choose React (Vite) and generate an API key with all scopes checked.

    Integrate

  4. Success! ๐ŸŽ‰ Now you just have to follow the integration guide.

Let's integrate it into React Appโ€‹

  1. Generate a brand new React App and open it to your favorite editor

    npm create vite@latest tolgee-hello-world -- --template react-ts
    # follow the vite guide
  1. Install Tolgee packages โฌ‡๏ธ

    npm install @tolgee/react
  2. Add Tolgee properties to your development .env file env.development.local by copying it from the integration guide

    VITE_APP_TOLGEE_API_URL=https://app.tolgee.io
    VITE_APP_TOLGEE_API_KEY=<your API key>
  3. Wrap your App component in main.tsx with TolgeeProvider component. Again, you can copy it from the integration guide.

  4. Go to App.tsx and replace all the crap with a simple "Hello world!" message.

    import './App.css';

    function App() {
    return (
    <div className="App">
    <h1>Hello world!</h1>
    </div>
    );
    }

    export default App;
  5. Wrap the "Hello world!" with <T> component and add keyName prop.

    import './App.css';
    import { T } from '@tolgee/react';

    function App() {
    return (
    <div className="App">
    <h1>
    <T keyName="hello_world">Hello world!</T>
    </h1>
    </div>
    );
    }

    export default App;
  6. Let's run the App in the browser and see the magic! ๐Ÿช„ Hold your ALT key and move your mouse over the text. It should be highlighted. When you click it, a dialog opens, and you're able to edit the text โœ๏ธ or generate screenshots. ๐Ÿ“ท

    In-context translation of hello_world key After you hit the update button, your Hello World! text will be immediately changed to the new value!

    The result

Congratulations! You're done! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰โ€‹

You can find the resulting code in this GitHub repo, but you have to add your .env.development.local file.

Now, you are able to translate your React applications with Tolgee. To learn more about Tolgee or to find out how to translate more complicated cases, visit our docs or integrations to other frameworks.

TL;DRโ€‹

Tolgee for React provides a simple API to create a multi-lingual React application. With Tolgee i18n library for React, you can enjoy all Tolgee i18n features.

Tolgee is an open-source tool simplifying the process of web-based application. It has these features:

  • It's an open-source and free localization (i18n) tool
  • You can translate in the context of your React app
  • You can generate screenshots automatically
  • Open-source localization platform included
  • Localize the React app with Tolgee fast and save time!
Do you have any question about React localization?

Join the Tolgee Slack community to explore more tips on how to localize your React app fast!

๐Ÿ™๐Ÿ™๐Ÿ™ If you like what we do, please star our GitHub projects. ๐Ÿ™๐Ÿ™๐Ÿ™

  • Tolgee Platform โญ Developer & translator-friendly web-based localization platform
  • Tolgee JS โญ Tolgee JavaScript libraries monorepo

React banner