Translations for my plugin don’t show up


I’m pulling my hair out with this one:

I want to provide translations for my plugin, but they’re not showing up. I followed the documentation and took the following steps:

  1. Set up local wordpress using docker
  2. Added Text Domain to Plugin-Info * Text Domain: my-plugin
  3. Added Domain Path to Plugin-Info * Domain Path: /languages/
  4. Added translation loading to plugin.php:
add_action( 'plugins_loaded', 'load_i18n' );
function load_i18n() {
  load_plugin_textdomain("my-plugin", false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
  1. I have a settings.php which is responsible for rendering my plugin’s Settings page and is initialized from plugin.php. I added this line there to test my translation: <?php _e( 'Hello, dear user!', 'my-plugin' ); ?>

  2. I used wp i18n make-pot to create the pot file. It successfully detects the line in settings and the plugin info stuff and creates what looks like a proper my-plugin.pot inside my plugin’s language directory.

  3. I used PoEdit to create translations from that pot file. I made en_US.po and inside the language directory. I translated my test string in the settings page as well as the plugin description.

  4. Set WordPress language to en_US via general settings. (I also tried define ('WPLANG', 'en_US'); inside wp_config.php)

  5. Installed my plugin.

Translations don’t show up (original text is displayed), neither in the plugin description nor the settings page.
I also tried other hooks for loading the text domain and other languages. The plugin is not going to be uploaded to the plugin repository, so the translations need to come with the plugin directly.

Mepsipax 2 months 2021-10-05T07:37:01-05:00 0 Answers 0 views 0

Leave an answer