25 lines
636 B
Markdown
25 lines
636 B
Markdown
|
|
How To Use
|
|
|
|
Put your translation JSON files inside locales directories anywhere under your project or working directory.
|
|
|
|
Each JSON file must be named as the language code, e.g., en.json, es.json.
|
|
|
|
Make sure you have a .env file with a locale variable defining your default language code (eg locale=en).
|
|
|
|
Start the loader
|
|
|
|
Just import or run this script — it immediately:
|
|
|
|
Loads all translation files it finds.
|
|
|
|
Starts a background thread watching those files for any edits.
|
|
|
|
Set language
|
|
|
|
Call set_language("fr") to switch the active locale dynamically.
|
|
|
|
Fetch translations
|
|
|
|
Use _('some.key') anywhere to get the localized string.
|
|
|