October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Internationalize a WordPress Block Theme

A practical guide to translating WordPress block themes across PHP templates, JavaScript editor code, patterns, and generated language files.
Length11 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Internationalizing a WordPress block theme means giving every user-facing string a consistent text domain, translating both PHP-rendered and editor-side JavaScript text, extracting those strings into translation files, and testing the theme in each target locale. A reliable implementation uses the theme slug as its text domain, WordPress i18n functions in PHP, @wordpress/i18n in JavaScript, PHP pattern files where authored copy needs translation hooks, and WP-CLI to produce the PO and JSON files WordPress loads.

What internationalization changes in a block theme

Internationalization (often shortened to i18n) prepares a theme for translation without tying its code to one language. Translation is the later step of supplying a locale’s translated catalog. In a block theme, that work spans more than a conventional template directory: users edit templates and template parts in the Site Editor, theme metadata lives in style.css, patterns may contain authored copy, and editor enhancements can run as JavaScript.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The practical rule is simple: every string displayed to a visitor or an administrator must be passed through the appropriate WordPress localization API. A heading, button label, accessibility label, notice, placeholder, or error message that remains hardcoded cannot be translated through the normal catalog.

Where the text runs Typical source Required approach
Server-side rendering PHP templates, pattern files, setup code Use WordPress PHP i18n functions with the theme text domain.
Editor or front-end scripting Bundled JavaScript that adds controls, notices, or labels Import functions from @wordpress/i18n, declare wp-i18n as a dependency, and load script translations.
Block markup and template content Static HTML in templates or patterns Use translatable block attributes where available; move authored strings to a PHP pattern when static markup cannot provide a translation hook.
Translation catalogs PO, MO, and JavaScript JSON files Extract with WP-CLI, convert JavaScript catalogs to JED 1.x JSON, and place files where WordPress expects them.

Choose and declare one text domain

Match the theme slug

Use a unique, lowercase, kebab-case text domain that exactly matches the theme slug. WordPress’s theme guidance requires the text domain to match the slug for correct translation handling. If the directory is named arcade-blocks, use arcade-blocks in every localization call; do not alternate between a display name, an underscored variant, and the slug.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Declare the domain in the theme header in style.css:

/*
Theme Name: Arcade Blocks
Text Domain: arcade-blocks
*/

Theme metadata is parsed from this header even when the theme is primarily composed of blocks. Keep the value synchronized if the directory or slug changes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Declare a custom language directory when you ship files

If translation files live in a directory supplied by the theme rather than the standard language-pack location, add a Domain Path header. The path is relative to the theme directory, for example:

/*
Theme Name: Arcade Blocks
Text Domain: arcade-blocks
Domain Path: /languages
*/

Use the same directory convention for the PO, MO, and JavaScript JSON files you distribute. A domain declaration does not translate anything by itself; it only gives extraction tools and loaders a consistent identity.

Internationalize PHP templates and pattern code

Use the function that matches the message

Wrap each PHP string at the point where it is produced. The common functions are:

Function Use it for Example
__() Return a translated string. __( 'Play now', 'arcade-blocks' )
_e() Echo a translated string directly. _e( 'Continue', 'arcade-blocks' )
_x() Return a translation with an explicit context for an ambiguous word. _x( 'Save', 'verb', 'arcade-blocks' )
_n() Select singular or plural text according to a count. _n( '%s level', '%s levels', $count, 'arcade-blocks' )
Escaping variants Translate and escape for the output context. Use the appropriate escaped form when outputting an attribute, HTML text, or another context that requires escaping.

Every call must contain the same domain declared in style.css. Context is important when one source word has different meanings. “Play” as a verb and “play” as a noun should use separate contexts so translators can distinguish them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Handle plurals with the count, not string concatenation

Do not choose a plural by concatenating a number onto a singular sentence. Pass the count to _n() so locales with more than two plural forms can choose the correct translation. Keep the placeholder in both forms and let WordPress format the result:

$count = 3;
$message = sprintf(
    _n( '%s level', '%s levels', $count, 'arcade-blocks' ),
    number_format_i18n( $count )
);

The translation function determines grammatical form; sprintf() inserts the localized number. Do not assume that every language uses the same singular/plural rule as English.

Escape for the destination

Translation does not make a string safe for every output context. Use an escaping variant or escape the returned translation for the destination: HTML text, an attribute, a URL, or JavaScript each has different requirements. Keep markup out of a translatable sentence where possible. When markup is necessary, give translators a clear sentence and preserve the tags consistently.

Translate editor-side JavaScript

Import WordPress’s i18n APIs

JavaScript used by the block editor has its own runtime APIs. Import __, _x, _n, or related functions from @wordpress/i18n, and pass the same theme domain:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { __, _x, _n } from '@wordpress/i18n';

const label = __( 'Featured level', 'arcade-blocks' );
const action = _x( 'Save', 'verb', 'arcade-blocks' );
const summary = _n( '%s item', '%s items', count, 'arcade-blocks' );

Do not substitute a JavaScript-only domain. A catalog can contain PHP and JavaScript entries under the same domain, while the execution contexts and loading mechanisms remain distinct.

Declare the wp-i18n dependency

The generated script must list wp-i18n as a dependency so WordPress loads the localization runtime before your bundle. If you register scripts manually, include that dependency in the registration call. If a build system creates the asset dependency metadata, verify that the resulting registration still includes wp-i18n.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Register translations before the script runs

For a registered script handle, WordPress provides wp_set_script_translations(). Call it after registering the handle and before enqueuing or executing the script. WordPress can then find the JSON catalog for the active locale and make the translated entries available to @wordpress/i18n.

wp_register_script(
    'arcade-blocks-editor',
    get_theme_file_uri( 'build/editor.js' ),
    array( 'wp-i18n', 'wp-blocks', 'wp-element' ),
    null,
    true
);
wp_set_script_translations(
    'arcade-blocks-editor',
    'arcade-blocks'
);
wp_enqueue_script( 'arcade-blocks-editor' );

The optional path argument is useful when JSON files are stored outside the default theme language directory. The path must point to the directory containing the generated script catalogs, not to an individual catalog file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make authored block-pattern text translatable

Know the limitation of static markup

A static pattern containing literal copy is not automatically a PHP translation call. Text placed directly in markup may be inserted into content as authored text, so changing the site locale later does not necessarily replace it. This is especially important for reusable starter layouts, calls to action, headings, and descriptions that the theme author—not the site owner—wrote.

Move translatable copy into a PHP pattern

A PHP pattern file can call WordPress internationalization functions while constructing the pattern. Use this approach when a pattern needs a translated default heading, button label, or other authored sentence:

<?php
/**
 * Title: Featured level
 * Slug: arcade-blocks/featured-level
 * Categories: arcade
 */

$heading = esc_html__( 'Featured level', 'arcade-blocks' );
$button  = esc_html__( 'View level', 'arcade-blocks' );
?>
<!-- wp:heading -->
<h2 class="wp-block-heading"><?php echo $heading; ?></h2>
<!-- /wp:heading -->
<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link"><?php echo $button; ?></a></div>
<!-- /wp:button -->

Use the escaping function that matches the eventual output. Keep the pattern metadata and the translatable sentence understandable to translators, and use the theme domain consistently.

Distinguish theme defaults from site content

Once a user inserts a pattern, its text may become ordinary post content that the user can edit. Internationalize the default authored text supplied by the theme; do not assume that user-written content should be translated by the theme. This distinction prevents a locale switch from unexpectedly replacing editorial content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Extract strings with WP-CLI

Create the POT catalog

From the project directory, run the WP-CLI i18n extraction command:

wp i18n make-pot ./ languages/arcade-blocks.pot

The first path is the theme source and the second is the destination POT file. Adjust those paths to your directory layout, but retain the theme’s exact domain in the source calls. Review the generated catalog for missing strings, incorrect domains, and accidental developer-only text.

Review the extracted entries

Before handing the POT file to a translator, check that:

  • PHP strings include the intended domain and any needed context.
  • Plural entries contain both singular and plural source forms.
  • JavaScript calls use imports from @wordpress/i18n and the same domain.
  • Pattern PHP files are scanned and their strings appear in the catalog.
  • Comments that explain placeholders or context are present where translators need them.

Extraction finds source strings; it does not translate them. A translator or localization workflow creates the locale-specific PO file from the POT template.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate JavaScript JSON catalogs

WordPress’s JavaScript runtime consumes JED 1.x JSON files rather than a raw POT. Convert PO files with WP-CLI’s JSON command:

wp i18n make-json ./languages ./languages

Use the actual PO source and JSON destination directories in your project. The command creates locale-specific JSON catalogs from the PO files. Keep the generated files in version control when the theme ships its own translations, or generate them as part of the release process.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Understand the generated filename

Script translation filenames encode the text domain, locale, and script identity. Depending on how the script is registered and how the files are generated, WordPress uses the documented domain-locale-handle or domain-locale-path-hash naming scheme. A JSON file with a correct translation but an incorrect handle, path, locale, or domain will not be associated with the script.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Deliver and load translation files

Use WordPress.org language packs when the theme is distributed there

The WordPress.org distribution system can download language packs into wp-content/languages. For a directory-hosted theme, this is the normal route: the site language determines which pack is installed, and WordPress loads the theme’s translated PHP strings from the matching files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Users still need the site configured to the desired language, and the theme must use the exact slug-matching domain. A mismatch in either value prevents an otherwise valid catalog from being used.

Ship custom files in the theme’s language directory

For a custom distribution, place PO, MO, and generated JavaScript JSON files in the directory declared by Domain Path, or use the documented theme language-directory loading functions. Keep locale codes and filenames exactly as generated. If JavaScript files are outside the default location, pass that directory as the optional path to wp_set_script_translations().

PHP and JavaScript files are loaded separately. Seeing a translated heading rendered by PHP does not prove that an editor-side notice or inspector label has a working JSON catalog.

Test in a real target locale

Set the site language

  1. In the WordPress dashboard, open Settings and then General.
  2. Change Site Language to the locale you want to test and save the setting.
  3. Install or place the corresponding theme language files where WordPress can read them.
  4. Open the Site Editor and a front-end page that exercises the theme’s templates, patterns, and scripts.

Test with a locale whose grammar differs from English when possible. This exposes assumptions about word order, plural forms, text expansion, and context that an English-only check will miss.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check both rendering contexts

  • View a front-end template containing PHP-translated headings, labels, and notices.
  • Insert each translatable pattern into a new page and verify its default authored copy.
  • Open the Site Editor and inspect every custom control, toolbar label, placeholder, and notice supplied by JavaScript.
  • Exercise singular and plural states, including zero, one, and several items where the UI supports them.
  • Inspect attributes and accessible names to ensure escaping did not remove or corrupt translated text.

Clear stale assets before diagnosing a failure

When a new JSON catalog appears not to load, ensure the updated script is being served and that the registered handle, locale, domain, and catalog filename agree. A browser or asset cache can preserve an older bundle, while a path or handle mismatch can make WordPress silently skip an otherwise correct file.

Common failures and precise fixes

Symptom Likely cause Fix
PHP text remains in English. The string is hardcoded, uses a different domain, or the locale catalog is not installed. Wrap the output in the correct PHP function, use the slug-matching domain, and verify the locale’s MO/language-pack file.
Editor labels remain in English while front-end text is translated. The JavaScript JSON catalog is missing, the script lacks wp-i18n, or translations were not registered for the handle. Regenerate JSON with wp i18n make-json, declare the dependency, call wp_set_script_translations(), and check the filename and path.
A pattern’s heading never changes with the site language. The copy is literal static markup or was saved as user content. Move theme-authored text into a PHP pattern and wrap it in an i18n function; treat already-edited site content as editorial data.
Only one of two identical words translates correctly. The source needs grammatical context. Use _x() with distinct context values and regenerate the catalog.
Plural text is grammatically wrong. Code concatenates a number or assumes English’s two-form rule. Use _n() with the count and provide translators with complete singular and plural source strings.
Translations work in one locale but not another. The locale-specific PO/JSON file is absent, misnamed, or stored in a directory WordPress does not scan. Generate the target locale’s files, preserve the documented naming scheme, and verify the configured language and loading path.

Choose the right implementation approach

Decision Use this when Trade-off
PHP i18n functions The text is rendered on the server or assembled by a PHP pattern. Works with PHP catalogs and normal theme loading, but cannot translate a string that exists only inside a separately loaded JavaScript bundle.
@wordpress/i18n The text appears in editor controls, notices, or other JavaScript UI. Requires the runtime dependency, script registration, and correctly named JSON catalogs.
Static block markup The text is intended as fixed structure or user-editable content rather than a theme-owned sentence. It does not provide a PHP translation hook for authored copy.
PHP pattern A theme-authored pattern needs translated defaults. Adds PHP to the pattern and requires the strings to be included in extraction.
WordPress.org language packs The theme is distributed through WordPress.org. Delivery is automatic for supported locales, but the theme must follow slug, domain, and catalog conventions.
Theme-shipped files You control distribution or need a custom language directory. You must package, name, update, and load the files correctly.

Release checklist for a localized block theme

  • The Text Domain header exactly matches the theme slug and uses lowercase kebab-case.
  • Domain Path is present when the theme ships translations in a custom directory.
  • Every user-facing PHP string uses an appropriate translation and escaping function.
  • Ambiguous terms have context and count-dependent messages use plural APIs.
  • JavaScript imports from @wordpress/i18n and uses the same domain.
  • Registered JavaScript handles declare wp-i18n before execution.
  • wp_set_script_translations() runs for each translated script, with a custom path when needed.
  • PHP pattern files contain translation calls for theme-authored copy that static markup cannot localize.
  • wp i18n make-pot output has been reviewed for missing or incorrectly attributed strings.
  • PO files have been converted with wp i18n make-json for JavaScript use.
  • Generated filenames follow the domain-locale-handle or domain-locale-path-hash convention.
  • At least one target locale has been tested in the Site Editor and on the front end, including plural and contextual cases.

A block theme is ready for translation when its metadata, PHP, patterns, JavaScript, extraction process, and runtime loading all agree on the same domain and locale. Treat those pieces as one pipeline: declare the identity first, wrap strings where they execute, generate the catalogs, place them in the path WordPress scans, and verify the result with the site set to a real target language.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.