Translate strings not recognised in plugin

I am trying to translate my plugin strings, but for some reason my plugin does not find the strings via the _e() and __() functions.

My plugin directory is called test-plugin.

My plugin /test-plugin/test-plugin.php files looks as follows:

<?php
/*
Plugin Name: Test plugin
Version: 1.0
Author: Robbert Vermeulen
License: GPL2
Text Domain: test-plugin
*/

_e( 'This is a test text', 'test-plugin' );
__( 'This is another test text', 'test-plugin' )


function test_plugin_load_plugin_textdomain() {
    load_plugin_textdomain( 'test-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'test_plugin_load_plugin_textdomain' );

?>

When I try to sync the strings the plugin only finds the values from my plugin description to translate.

enter image description here

What do I have to do so that the strings are recognized?

My test-plugin.pot file looks like:

#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Test plugin\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-13 16:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
"Language: \n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/"

#. Author of the plugin
msgid "Robbert Vermeulen"
msgstr ""

#. Name of the plugin
msgid "Test plugin"
msgstr ""

1 Answer
1

I just needed to update the template (.pot) file each time and then sync the language.

Leave a Comment