Development Guides
Development of MiniApps is not rocket science! Here are some guides to help you.
Localizing your MiniApp

This section covers localizing your MiniApp to the user's device's language settings. 

Typical data types to localize.

  1. Static strings
  2. Assets(images, video, etc.)
  3. Data from API calls

Getting the preferred language(s) from the device

Get the locale value from Navigator

There is getLocale function under ./utils/getLocale.js
In the response to this function we look for navigator.language property. It typically looks like this 'en-US', 'ja-JP'

The first two characters are the language property (what we want right now. The second two are the locale (country or region).

Double check the language property works for you

Your MiniApp may support specific languages, but the user's device may not be set to one of them. To solve for this, please ensure that you specify a backup should the user's preferred languages not match any language you support.

React JS:The following instructions are tailored to React JS. The specific steps for other frameworks will vary, but the concept is the same.

Localizing static strings

The following steps are required to localize static strings throughout the app

  1. Identify all the static text in your app that needs to be translated
  2. Create the folder "translation" under your source code's root directory (src).
  3. Create .json files for each locale you are planning for e.g. en.json for English, ja.json for Japanese, fr.json French, and so on
  4. Create index.js under translations folder
  5. Import all the .json files those you created
  6. Export an object called messages with key as language name.

    Json file structure will look like this

  7. Install react-intl to your project `npm i react-intl`
  8. Configure react-intl to your app's index.js page like below



        9. Now import formatted message and change the control id according to the JSON page you created for localization


Run the app and check for the changes as you change the language from your browser

Localizing static assets

Follow these steps for localizing assets in your project

  1. Create index.js under your assets folder
  2. Import all required assets 
  3. Export an object called assets with each key as a locale and each value as page. Under each page create key/value pairs for the assets you imported, like below
  4. configure the assets in your app's index.js file like below


       5.Pass the asset as prop

Run the application to see your desired assets replaced on language change

Call API according to locale

As you have locale value as a prop in your component, every get api call you make should have locale as query parameter

like `` 

Once you complete all the steps stated above you should be able to localize your MiniApp.

move to top