agentleFS
AnyOrgNameAnyOrgName/php-skills/skills/bitrix/localization/SKILL.md

localization

Skill4 starsChanged 4 months agoMITView on GitHub

Localize 1C-Bitrix code with the D7 `Loc::getMessage` API and language files — message codes, module versus component lang directories (`lang/ru`, `lang/en`), parameter substitution, and plural forms — instead of hard-coded strings. Use when the user needs to create or place Bitrix language files and asks where they go (`lang/ru`, `lang/en`) and how the path mirrors the source file for a module or component; пользователь подставляет значения в локализованное сообщение (`#PARAM#`) или обрабатывает множественные формы в Битрикс и спрашивает, как передать параметры в `Loc::getMessage()`; the user needs to output a translatable, user-facing string in Bitrix code and asks how to use `Loc::getMessage()` and a message code instead of a literal. Keywords: bitrix, localization, loc, getmessage, lang, i18n, d7, legacy, битрикс, локализация, язык.

21 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ab-test-store-listing, app-analytics and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • appeekySkill

    ab-test-store-listing

    When the user wants to A/B test App Store product page elements to improve conversion rate. Also use when the user mentions "A/B test", "product page optimization", "test my screenshots", "test my icon", "conversion rate optimization", "CPP", or "custom product pages". For screenshot design, see screenshot-optimization. For metadata optimization, see metadata-optimization.

    Also in 3 projects that use this

  • appeekySkill

    app-analytics

    When the user wants to set up, interpret, or improve their app analytics and tracking. Also use when the user mentions "analytics", "tracking", "metrics", "KPIs", "App Store Connect analytics", "install tracking", "funnel", "attribution", or "how is my app performing". For A/B testing, see ab-test-store-listing. For retention metrics, see retention-optimization.

    Also in 3 projects that use this

  • +10 more from appeeky

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not use this skill for translating stored content (iblock elements per site or language).

    line 70
  2. Very specific:

    Do not use this skill on a non-Bitrix PHP app.

    line 73
  3. Very specific:

    Create lang/ru/<file>.php and lang/en/<file>.php next to the source file, each returning $MESS['VENDOR_MODULE_HELLO'] = '...'.

    line 93
  4. Very specific:

    Place each message file at a path that mirrors the calling file under lang/<lang-code>/ (e.g

    line 102
  5. Distinctive:

    Not applicable — no I/O, auth, or untrusted input.

    line 146

“Common” is measured: kept by at least 6 in 10 of the 19 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- generated: do not edit — source: knowledge/atoms/bitrix/localization/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->

Bitrix Localization

When to use

  • The user needs to create or place Bitrix language files and asks where they go (lang/ru, lang/en) and how the path mirrors the source file for a module or component.
  • Пользователь подставляет значения в локализованное сообщение (#PARAM#) или обрабатывает множественные формы в Битрикс и спрашивает, как передать параметры в Loc::getMessage().
  • The user needs to output a translatable, user-facing string in Bitrix code and asks how to use Loc::getMessage() and a message code instead of a literal.

When NOT to use

  • Do not use this skill for translating stored content (iblock elements per site or language); that is modelled with multi-site/multi-language content, not Loc::getMessage lang files.
  • Do not use this skill on a non-Bitrix PHP app; Loc::getMessage, the lang-file layout, and IncludeModuleLangFile are Bitrix-specific.

Core guidance

  • Keep user-facing text in lang files, not inline — Move every user-facing phrase into a lang file keyed by a message code and reference it through Loc::getMessage; do not hard-code display strings in PHP, templates, or components.
  • Pass dynamic values as named parameters — Put placeholders like #COUNT# in the message text and pass values as the second getMessage argument (['#COUNT#' => $n]) instead of concatenating strings around a fragment.
  • Prefer Loc::getMessage over legacy GetMessage — In new code, call \Bitrix\Main\Localization\Loc::getMessage('CODE') (after Loc::loadMessages(__FILE__) where needed) instead of the legacy global GetMessage('CODE').

Quick recipe

  1. At the top of the PHP file add use Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__);, then output the text with Loc::getMessage('VENDOR_MODULE_HELLO'). (verify: The code compiles and getMessage returns a value once the lang file exists.)
  2. Create lang/ru/<file>.php and lang/en/<file>.php next to the source file, each returning $MESS['VENDOR_MODULE_HELLO'] = '...'; for that language. (verify: Each language directory has a message file with the same code.)
  3. For dynamic text, write $MESS['VENDOR_MODULE_FOUND'] = 'Found #COUNT# items'; and call Loc::getMessage('VENDOR_MODULE_FOUND', ['#COUNT#' => $count]);. (verify: The placeholder is replaced by the value in the rendered output.)

Best practices

  • Give message codes a stable, prefixed, uppercase name tied to the module or component (e.g
  • Place each message file at a path that mirrors the calling file under lang/<lang-code>/ (e.g
  • In module code call Loc::loadMessages(__FILE__) once per file (or the legacy IncludeModuleLangFile(__FILE__)) before reading messages, rather than assuming another file already loaded them

Anti-patterns

Anti-patternWhy it failsDo instead
Concatenating translated fragmentsWord order and grammar differ per language, so gluing fragments produces broken translations.Use one message with placeholders (Found #COUNT# items) and pass values via the<br>parameters array so translators control the whole sentence.
Reusing generic, unprefixed message codesGeneric codes collide when message sets merge, so an unrelated phrase can silently override yours.Prefix codes with the module/component namespace and keep them unique<br>(VENDOR_CATALOG_TITLE), so no two files clash.
Hard-coding display text in templatesInline literals cannot be translated per language and bypass the message-code catalog.Replace the literal with a Loc::getMessage('CODE') call and add the phrase to<br>each language's lang file.

See references/anti-patterns.md.

Common mistakes

  1. Lang file encoding not matching the site — Saving a lang file in an encoding that differs from the site's charset (UTF-8 vs windows-1251) renders Cyrillic and other non-ASCII text as mojibake. Fix: Save every lang file in the site's charset (UTF-8 on modern installs) and keep all languages consistent with the core encoding.
  2. Adding a code to one language only — Adding a message code to lang/ru but not lang/en (or vice versa) makes the code render literally for every visitor on the missing language. Fix: Add each new code to every supported language directory at the same time, even if the initial value is a placeholder pending translation.
  3. Calling getMessage without loading the file's messages — Calling Loc::getMessage('CODE') without a prior Loc::loadMessages(__FILE__) (in entry points like AJAX handlers, agents, or CLI) returns the raw code string instead of the translation. Fix: Call Loc::loadMessages(__FILE__) once near the top of every file that reads messages, especially standalone entry points.
  4. Lang file path not mirroring the source file — Putting the lang file at a path that does not mirror the calling file (wrong directory or wrong filename under lang/<code>/) makes Bitrix fail to find the messages, so codes render literally. Fix: Place the lang file at the exact mirrored path (same subdirectories and filename) under each lang/<lang-code>/, matching the file that calls getMessage.

Version notes

  • Loc supersedes the global GetMessage on modern cores — The D7 \Bitrix\Main\Localization\Loc class (getMessage, loadMessages) is the current API; the global GetMessage() and IncludeModuleLangFile() remain as legacy helpers over the same lang files for older code.
  • PHP support tracks the Bitrix core version — Modern Bitrix cores run the localization API on PHP 7.4 through 8.2; the API and lang-file format were not certified past 8.2 at the time of writing, so avoid relying on PHP 8.3+ syntax in localized code.

Security

  • Not applicable — no I/O, auth, or untrusted input.

Testing

  • Activation and decision behavior are verified in eval/scenarios/bitrix/localization.yaml.

Additional resources

  • references/anti-patterns.md
  • references/core.md
  • references/examples.md
  • references/pitfalls.md
  • references/recipes.md
  • references/version-differences.md

Knowledge graph

Prerequisites: bitrix/kernel-main-module

<!-- graph-fragment: graph/fragments/bitrix/localization.yaml -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.