i18n Localizations

Internationalisation

SynaptikCMS has a two-track i18n system: one for the front-end and one for the admin panel.


Locale files

ScopePathFormat
Front-end/lang/{locale}.jsonJSON key/value
Admin/lang/admin/{locale}.jsonJSON key/value

How it works

On the first request, lang_load() reads settings.json to find active_language, loads the locale JSON, generates an OPcache-friendly PHP cache in lang/cache/{locale}.php, and stores it in $GLOBALS['_LANG_STRINGS'].

The cache is invalidated automatically if the source .json is newer.

JS bridge — inject in header.php:

window.CMS_LANG = ;

URL slugs

Defined per locale, drive routing, URL generation, and the admin simultaneously:

"url_slug_article":  "article",
"url_slug_articles": "articles",
"url_slug_project":  "project",
"url_slug_projects": "projects",
"url_slug_page":     "page",
"url_slug_pages":    "pages",
"url_slug_category": "category",
"url_slug_tag":      "tag"

Output helpers

_e('new_article');                                           // Echo
$label = __t('new_article');                                 // Return
printf(__t('media_files_size'), admin_format_file_size($s)); // Placeholder

Adding a new string

  1. Add the key/value to every locale file in /lang/ and /lang/admin/ as appropriate.
  2. Never hardcode a user-visible string in PHP — always use an i18n key.

Adding a new language

  1. Copy lang/en.jsonlang/{locale}.json
  2. Copy lang/admin/en.jsonlang/admin/{locale}.json
  3. Translate all values
  4. Set "active_language": "{locale}" in settings.json

ℹ️

All code comments and function docblocks must be in English. Only the values inside locale JSON files are translated.