I am using Divi theme and Polylang plugin. I use Polylang to add Bosnian language (bs_BA). I know how to register strings for Polylang and translate them that way, but I can't manage to do plurals correctly, since Bosnian has different forms for 1, 2-4, and 5+, so I tried using POEDIT. I've added this to my child theme's functions.php file:

    function my_lang_function() {
        load_child_theme_textdomain( "Divi", get_stylesheet_directory() . "/includes/builder/languages" );

    add_action( "after_setup_theme", "my_lang_function" );

This is a line that I have in my custom module:

    $output.="<li class='bedroom'>".sprintf(_nx("%d bedroom", "%d bedrooms", $custom["bedroom_count"][0], "noun", "custom-strings"), $custom["bedroom_count"][0])."</li>";

I have created a bs_BA.po file and put it in /includes/builder/languages folder, compiled it to .mo and put it there too:

# Translation of Divi custom modules to Bosnian
msgid ""
msgstr ""
"PO-Revision-Date: 2018-09-14 20:09+0200\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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"
"X-Generator: Poedit 1.8.11\n"
"Language: bs_BA@latin\n"
"Project-Id-Version: Divi \n"
"POT-Creation-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Poedit-KeywordsList: _n:1,2,3\r_n_noop:1,2,3\r_nx:1,2,3\r_nx_noop:1,2,3\n"

msgid "bedrooms"
msgstr "test bedrooms"

msgid "bedroom"
msgstr "test bedroom"

I still see only English and I don't know what I'm doing wrong.

closed as off-topic by Michael, Jacob Peattie, bosco, Jack Johansson Sep 18 '18 at 0:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  1. It seems that you're adding translatable strings with text domain "custom-strings" but loading a text domain "Divi" in load_child_theme_textdomain. Needs to be the same

  2. Don't use the same text domain as your parent theme. If your parent theme is Divi, use divi-child (it should match your child theme slug).

  3. In your child theme's style.css, define the Text Domain.

  4. I've read somewhere that the path to the child theme's .po and .mo files should be the same as the parent's, but I'm unsure about this. Your path seems custom (not sure) so include it in your child theme's style.css as well.


In functions.php:

function my_lang_function() {
    load_child_theme_textdomain( "divi-child", get_stylesheet_directory() . "/includes/builder/languages" );

add_action( "after_setup_theme", "my_lang_function" );

In whatever file:

$output.="<li class='bedroom'>".sprintf(_nx("%d bedroom", "%d bedrooms", $custom["bedroom_count"][0], "noun", "divi-child"), $custom["bedroom_count"][0])."</li>";

In style.css:

Text Domain: divi-child
Domain Path: /includes/builder/languages
  • thanks! I did all that, but still no change. How could I check if my bs_BA.mo is even loaded? – ivanacorovic Sep 15 '18 at 7:11
  • So I don't know how Polylang works as I use Loco Translate, but should be +/- the same. The plugin should allow you to create a .pot file. It is this .pot file that is fed with the translatable strings, and from which you create a .po file. Everything in your configuration should be fine now, try to create the .pot file with your plugin – Gonçalo Figueiredo Sep 15 '18 at 15:00

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