logo

The init function is used to load language files from a given directory. It requires the path to the folder containing the .json language files and an array of language codes to load.

Function Format:

Lang.init(folder:String, langs:Array, ?traceCompleted:Bool);

And below, an example.

Usage (example):

Lang.init("assets/data/lang/", ["pt", "en", "es", "fr", "ru"], false);

folder: The folder path containing .json language files. languages: An array of language codes to load (e.g., ["en", "fr", "es"]). traceCompleted (optional): A boolean flag to trace the number of languages loaded.

If running in a JavaScript environment, it will use asynchronous HTTP requests to fetch the files.

Example (for JavaScript):

Lang.init("assets/langs", ["en", "fr", "de"], true);

This will load the en.json, fr.json, and de.json files from the assets/langs directory and log the number of languages loaded.

Example (for Haxe System):

Lang.init("assets/langs", ["en", "fr", "de"], true);

For the sys target, this will load the language files synchronously from the file system.