In this article

Internationalization

Where applicable, please strive for making all strings available for translation. Consider the following guidelines when doing so:

PHP

  • Instead of __, _e, _x and similar functions, use their safe versions: esc_html__, esc_html_e, esc_html_x and others where possible.
  • Use an appropriate unique text domain in your plugin or Composer package.
  • Make use of our Automattic/jetpack-composer-plugin and related packages to ensure i18n works in the published plugin.

JavaScript

  • Use Gutenberg’s @wordpress/i18n package.
  • Use an appropriate unique text domain in your JS code.
  • Make use of @automattic/babel-plugin-replace-textdomain when building to ensure i18n works in the published plugin.
  • When using TypeScript in Webpack, use @babel/preset-typescript rather than ts-loader.
    • To generate .d.ts files, either fork-ts-checker-webpack-plugin or tsc --emitDeclarationOnly may be used.