Documentation section

Metadata File

Learn about how to generate metadata file with the list of available languages and plural rules.

To allow you fully automatize the localization of your mobile, desktop or web app, Localazy can generate useful metadata files.

It contains basic information about the project and the list of languages, their English and localized names, information about language, region and script. For selected formats, expressions for calculating correct plural types are included.

You can use metadata files to:

  • show language selector for users
  • automatically determine the best language to use
  • navigate uses to your project on Localazy to help you with translating it
  • use correct plural forms without including 3rd party libraries
  • and more…

Generating metadata file 🔗

You can generate metadata file by including metadataFileJson, metadataFileJs and/or metadataFileTs in the download section of your localazy.json file.

{
    "download": {
      "metadataFileJson": "languages.json",
      "metadataFileJs": "languages.js",
      "metadataFileTs": "languages.ts"
    }
}

You can include all of the above to generate all variants.

JSON format 🔗

The metadata file in JSON format is generated to the file specified by metadataFileJson. This format doesn’t include plural type expression.

{
    "projectUrl": "https://localazy.com/p/...",
    "baseLocale": "en",
    "languages": [
        {
            "language": "ko",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "Korean",
            "localizedName": "한국어"
        },
        {
            "language": "de",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "German",
            "localizedName": "Deutsch"
        },
        {
            "language": "sk",
            "region": "",
            "script": "",
            "isRtl": false,
            "name": "Slovak",
            "localizedName": "Slovenčina"
        },

        // ...

    ]
}

Javascript format 🔗

The metadata file in Javascript format is generated to the file specified by metadataFileJs. It’s a Javascript module, and you can include it out-of-the-box to your code.

It comes with an expression for determining the correct plural type.

const localazyMetadata = {
  projectUrl: "http://localhost:9091/p/floating-apps-2",
  baseLocale: "en",
  languages: [
    {
      language: "ko",
      region: "",
      script: "",
      isRtl: false,
      name: "Korean",
      localizedName: "한국어",
      pluralType: (n) => { return "other"; }
    },
    {
      language: "de",
      region: "",
      script: "",
      isRtl: false,
      name: "German",
      localizedName: "Deutsch",
      pluralType: (n) => { return (n===1) ? "one" : "other"; }
    },
    {
      language: "sk",
      region: "",
      script: "",
      isRtl: false,
      name: "Slovak",
      localizedName: "Slovenčina",
      pluralType: (n) => { return (n===1) ? "one" : (n>=2 && n<=4) ? "few" : "other"; }
    }
  ]
};

export default localazyMetadata;

Typescript format 🔗

The metadata file in Typescript format is generated to the file specified by metadataFileTs. It’s a Typescript module, and you can include it out-of-the-box to your code.

It contains information about types and comes with an expression for determining the correct plural type.

export type LocalazyLanguage = {
    language: string;
    region: string;
    script: string;
    isRtl: boolean;
    localizedName: string;
    name: string;
    pluralType: (n: number) => "zero" | "one" | "two" | "many" | "few" | "other";
};

export type LocalazyMetadata = {
    projectUrl: string;
    baseLocale: string;
    languages: LocalazyLanguage[];
};
     
const localazyMetadata: LocalazyMetadata = {
  projectUrl: "http://localhost:9091/p/floating-apps-2",
  baseLocale: "en",
  languages: [
    {
      language: "ko",
      region: "",
      script: "",
      isRtl: false,
      name: "Korean",
      localizedName: "한국어",
      pluralType: (n) => { return "other"; }
    },
    {
      language: "de",
      region: "",
      script: "",
      isRtl: false,
      name: "German",
      localizedName: "Deutsch",
      pluralType: (n) => { return (n===1) ? "one" : "other"; }
    },
    {
      language: "sk",
      region: "",
      script: "",
      isRtl: false,
      name: "Slovak",
      localizedName: "Slovenčina",
      pluralType: (n) => { return (n===1) ? "one" : (n>=2 && n<=4) ? "few" : "other"; }
    }
  ]
};

export default localazyMetadata;