agentleFS
SnoozleStudioSnoozleStudio/opencode-wp-settings/skills/wp-i18n/SKILL.md

wp-i18n

Skill4 starsChanged 3 days agoMITView on GitHub

Make WordPress code translation-ready. Use when writing any user-facing string, adding text domains, fixing untranslated output, or preparing a plugin/theme for localization. Enforces the i18n escaping matrix, translators comments, numbered placeholders, and text-domain rules.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every user-facing string passes through a translation function.

    line 8
  2. Very specific:

    Never raw __( ) or _e() inside HTML — always the escaping variants.

    line 24
  3. Very specific:

    Translators comment: must immediately precede the gettext call and start with translators: — explains every placeholder

    line 32
  4. Distinctive:

    Don't translate markup — translate the text, escape at echo

    line 36
  5. Distinctive:

    Avoid near-duplicate strings (same wording, same punctuation)

    line 37
  6. Very specific:

    Use wp.i18n (wp_set_script_translations( 'handle', 'domain' ) after enqueue): wp.i18n.__(), sprintf(), _n() — never hardcoded UI strings in …

    line 49

“Common” is measured: kept by at least 6 in 10 of the 3 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

i18n — Translation-Ready WordPress Code

Every user-facing string passes through a translation function. No exceptions. Text domain = plugin/theme slug with dashes, passed as the LAST argument, never via variable/constant.

Function matrix

ContextFunction
Echo textesc_html_e( 'Text', 'domain' )
Return textesc_html__( 'Text', 'domain' )
Attributeesc_attr_e() / esc_attr__()
Context (noun vs verb)_x( 'Post', 'noun', 'domain' ) / esc_html_x()
Plural_n( 'item', 'items', $count, 'domain' )
Plural + context_nx()
Numbers/datesnumber_format_i18n(), date_i18n()

Never raw __( ) or _e() inside HTML — always the escaping variants.

String rules

  • No interpolation — use placeholders: printf( /* translators: %s: Name */ esc_html__( 'Welcome, %s', 'domain' ), $name );
  • Multiple placeholders: numbered %1$s, %2$d in single quotes (double quotes would interpolate $s)
  • Translators comment must immediately precede the gettext call and start with translators: — explains every placeholder
  • Full sentences, no leading/trailing whitespace, no URLs inside strings, no empty strings, no \r
  • Don't translate markup — translate the text, escape at echo
  • Avoid near-duplicate strings (same wording, same punctuation)

Loading

  • Themes: load_theme_textdomain( 'domain', get_template_directory() . '/languages' ) in the after_setup_theme setup function
  • Plugins: load_plugin_textdomain( 'domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ) on init
  • Header: Text Domain: domain + Domain Path: /languages in both

JS strings

  • Use wp.i18n (wp_set_script_translations( 'handle', 'domain' ) after enqueue): wp.i18n.__(), sprintf(), _n() — never hardcoded UI strings in JS for user-facing text

Audit

Grep for: __( / _e( without text domain, raw quotes around user-facing text in templates, interpolated $var inside __('... $var ...'), missing translators comments on placeholders. The WPCS WordPress.WP.I18n sniff catches most — run phpcs.

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.