skip to Main Content

I’m developing a large-scale application with React and node, which has a form builder, form assigning to user functionality, etc.
I need to add multi-language support for this application. Since there are large amounts of hardcode text and some user-generated text, How can I implement the functionality so it doesn’t affect performance?
I referred react-i18next library, which can be used for handling transition.

Also, I need to translate the values into multiple languages programmatically with the help of any online translation API ( probably Google Translate API if it is a good choice )

How can approach this issue?

2

Answers


  1. You mentioned react-i18next, and it’s a popular choice for handling translations in React applications. It works well with i18next, a powerful internationalization library. You can stick with this choice.

    Organize your project’s codebase to separate text content from components and logic. This will make it easier to manage translations. Create a folder structure for translations. For example, have separate JSON files for each language in a folder like src/locales. Replace hard-coded text in your components with translation keys. Also, initialize i18next in your main application file (e.g., App.js). Configure it with options like supported languages and fallbacks. You can also create language files by creating JSON files for each language you want to support. For instance, en.json, fr.json, etc., in the locales folder.

    For the user-generated content that needs to be translated, you can use an online translation API like the Google Translate API. You would programmatically send this content to the API when needed and store the translated text in your database.

    To maintain performance, utilize React’s virtual DOM for efficient rendering and keep translation files compact to speed up initial load times. This approach ensures smooth multi-language support integration in your React and Node application. Select a reliable translation API like Google Translate and be cost-conscious when dealing with extensive user-generated content translations.

    Login or Signup to reply.
  2. I think you can use the fuse react 4.0+ template as a reference. You can find there multi langauge support using react-i18next.
    You can check directly in this url.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search