I've set up everything according to the docs and compiled my translations using loco translate. For some Reason, I can't get the translations to work. It always prints out english. How can I get the translations to work? I posted this question on stackoverflow because I'm not sure whether this is an issue with gettext, wordpress or my code.
<?php
/**
* Plugin Name: myplugin
* Description: myplugindescription
* Author: Tom McLean
* Version: 1.0.0
* Text Domain: myplugin-domain
* Domain Path: /languages/
*/
function loadMyPluginTextDomain() {
load_plugin_textdomain(
'myplugin-domain',
false,
dirname(plugin_basename( __FILE__ )) . '/languages/'
);
}
add_action( 'plugins_loaded', 'loadMyPluginTextDomain');
_e('Learn More', 'myplugin-domain');
.pot file
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: myplugin
"
"Report-Msgid-Bugs-To:
"
"POT-Creation-Date: 2018-05-18 12:06+0000
"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>
"
"Language-Team:
"
"Language:
"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
"X-Generator: Loco https://localise.biz/"
msgid "Learn more"
msgstr ""
.po file
msgid ""
msgstr ""
"Project-Id-Version: myplugin
"
"Report-Msgid-Bugs-To:
"
"POT-Creation-Date: 2018-05-18 12:06+0000
"
"PO-Revision-Date: 2018-05-18 12:12+0000
"
"Last-Translator: Tom <tomm1996@gmail.com>
"
"Language-Team: Deutsch
"
"Language: de_DE
"
"Plural-Forms: nplurals=2; plural=n != 1;
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
"X-Generator: Loco https://localise.biz/"
msgctxt "Link text"
msgid "Learn more"
msgstr "Erfahren Sie mehr."
WP Config
define('WPLANG', 'de_DE');
- Wordpress Version: 4.9.6
- PHP Version: php-5.6.4