Hi!
A little help for you. This is not to difficult. Here is my function for this:
public function loadLanguage() {
$moFile = $this->languageDir . WPLANG . '.mo';
if (file_exists($moFile)) {
$dir = $this->pluginName . '/languages';
load_textdomain($this->pluginName, $moFile);
load_plugin_textdomain($this->pluginName, false, $dir);
} else {
trigger_error('The language you did set in the configuration.php is not exists in ' . $this->languageDir, E_USER_ERROR);
die();
}
}
this is load the en-EN.mo (or hu-HU, etc…) file from the wp-plugins/
After this, you can use 2 functions for translated texts:
one is _(“This is a string”, $this->pluginName);
(If your plugin name is slickQuiz, you can use it:
_(“This is a string”, “slickQuiz”);
but is more lucky, if you define a constant, define(“SQ_TEXT_DOMAIN”, “slickQuiz”); and after that, use:
_(“This is a string”, SQ_TEXT_DOMAIN);
so, _($str, SQ_TEST_DOMAIN); will echo the translated $str texts from the .mo file.
the other function is: __($str, SQ_TEST_DOMAIN);
with 2 underscores. it’s mean, it will return with the translated text, so you can use it as return values.
So, you should mage a language/ directory under your plugins root directory, make a catalog en-EN.po file here, set the sources path to “..” in poEdit progam (https://www.poedit.net/), refresh the catalog from source, and after this, everybody can translate it.
if you have any question about this, let me know.