Skip to main content

Localazy CLI Tips: Automated language switcher

Dan Charvát avatar
Written by Dan Charvát
Updated over 2 years ago

The metadata file 🔗

All you need to do is to tell Localazy CLI to export the so-called metadata file.

We’ve added support for metadata files in Localazy CLI 1.1.17, so be sure to keep your tools updated 😉

{
  "download": {
    "metadataFile": "languages.json",
    "files": "..."
  }
}

From that moment, when you invoke localazy download, the file languages.json will be generated with basic information about your project as well as a list of languages, including their English and localized name:

{
    "projectUrl": "<https://localazy.com/p/my-app>",
    "baseLocale": "en",
    "languages": [
        {
            "language": "ar",
            "region": "",
            "script": "",
            "isRtl": true,
            "name": "Arabic",
            "localizedName": "العربية"
        },
        {
            "language": "cs",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "Czech",
            "localizedName": "Čeština"
        },
        {
            "language": "en",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "English",
            "localizedName": "English"
        },
        {
            "language": "de",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "German",
            "localizedName": "Deutsch"
        }
    ]
}

Neat! You can load data for your language selector from this file and fully automate the localization. And you can control visible languages from Localazy! That’s the beauty of the single source of truth. 😁

You might also like

Read more Localazy CLI related articles!

Or, learn how to implement a language switcher into your Android app.

Did this answer your question?