1

Hi all I have one problem. Po file doesn't work. I use qtransltae-x for translation. And I create custom pot file

example

# Copyright (C) 2015 Gawatt
msgid ""
msgstr ""
"Project-Id-Version: Gawatt 1.0.0\n"
"POT-Creation-Date: 2015-06-03 11:30+0400\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"X-Generator: Poedit 1.8.1\n"

#: club.php:25
msgid "zibil"
msgstr ""

after that I generate it`

# Copyright (C) 2015 Gawatt
msgid ""
msgstr ""
"Project-Id-Version: Gawatt 1.0.0\n"
"POT-Creation-Date: 2015-06-03 11:30+0400\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2015-06-03 12:45+0400\n"
"X-Generator: Poedit 1.7.6\n"
"Last-Translator: \n"
"Language-Team: \n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Language: ru_RU\n"

#: club.php:25
msgid "zibil"
msgstr "sdfsdfsdfsdf"

code output `

<?php _e('zibil'); ?>

and in wp-config

define('WPLANG', 'ru_RU');

but when I switch language to russina it doesn't work, can you please help me thank you.

4

The define('WPLANG', 'ru_RU'); in the wp-config.php is no longer needed, as WordPress stores this value in the database (starting from version 4.0).

However, I suppose your problem is actually something different.

Your Steps:

Add a filter to locale

To ensure your language is set correctly, use a code like this:

add_filter( 'locale', 'f711_set_language' );
function f711_set_language( $locale ) {

    // you can use any switches to define the language here
    return 'ru_RU';

}

Use a textdomain

Change your Code to ensure your localized output is in a textdomain

<?php _e( 'zibil', 'your_textdomain' ); ?>

Be sure that you load the textdomain correctly

For Themes, you can use this. Be sure to define the right directory where your translation files are stored.

add_action('after_setup_theme', 'f711_load_theme_textdomain');
function f711_load_theme_textdomain(){
    load_theme_textdomain( 'your_textdomain', get_template_directory().'/languages' );
}

For Plugins, use this:

add_action( 'plugins_loaded', 'f711_load_plugin_textdomain' );
function f711_load_plugin_textdomain() {
    load_plugin_textdomain( 'your_textdomain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 
}

Be sure you named your .po correctly

The translation file HAS to be called ru_RU.po in your case.

You should be set up correctly afterwards.

  • 1
    Which step was the one that mattered? I suppose the loading of the textdomain? – fischi Jun 3 '15 at 10:26
  • I was editing a pre-built theme for a customer and since he bought an english one, I only had to set a filter for default locale and it worked. – Patrice Poliquin Dec 4 '17 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.