Please make sure to update to WPML 4.3.4 before reporting any issue

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem: Child theme text domain is ignored by String Translation and localization files.

Solution: Additional custom coding in functions.php was interfering with the registering of the Text Domain.

Relevant Documentation: https://developer.wordpress.org/reference/functions/load_child_theme_textdomain/

This topic contains 24 replies, has 3 voices.

Last updated by lucM-5 3 years, 4 months ago.

Assigned support staff: Yvette.

Author Posts
June 17, 2016 at 5:08 pm #917689

lucM-5

I am trying to: translate strings of child theme & have added the below to functions.php for child theme:

function twm_translations() {
load_child_theme_textdomain( 'lambda-child-theme', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'twm_translations');

I've uploaded .po &.mo files to corresponding directory. These files are also on language directory of parent theme, and do a fine job when the parent theme is activated.

URL of (my) website where problem appears: hidden link

I expected to see: Alle posts over Data analytics (which is the dutch translation of the text below) (and I do get this, when I activate the parent theme)

Instead, I got: All posts tagged: Data analytics

Steps to duplicate the issue:

June 19, 2016 at 11:23 am #918607

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Let me see if I can correctly restate your prolem to check my understanding:

You have a child theme and you have assigned a "child" text domain to it. There is a string generated by your theme: "All posts tagged: Data analytics".
You expected this string to be translated when you activated your Child Theme. However, it only shows up translated when the Parent theme is activated.

Questions:
1. Where is the string being generated? In a parent template or a child template file?

2. It it normal "localized" text using the gettext() format
codex: https://codex.wordpress.org/I18n_for_WordPress_Developers

3. Are there other strings also behaving in the same manner or is this the only one?

4. Are you using String Translations to translate the strings?

5. Have I restated the problem correctly?

Thanks for the additional info

June 19, 2016 at 1:25 pm #918646

lucM-5

Yvette, you restate my problem correctly. This translation problem actually applies to all strings that I have included in the nl.mo & nl.po files on the languages directory of my lambda child theme. So I'm trying pick up translations from those files, rather than using string translator because I have observed that string translator really slows down the backend (I have 256 MB memory defined).

To give an example, I made a copy of search.php to child theme directories & changed as follows:

get_header();
oxy_blog_header(__('Results for:', 'lambda-child-theme'). ' ' .get_search_query());
get_template_part('partials/blog/list/' . oxy_get_option('blog_style'));
get_footer();

but that doesn't seem to have any impact. Just to test & to be sure I identified the correct files for translation (there are only about 60 strings that need translation), I temporarily used string translation. By using the above procedure, I got the strings available for translation - but even then they never showed up in my web site's frontend.

To show you have I defined setup, I include screenshot. Despite the fact that my child theme has been activated, the MO-file related to the theme continues to refer to a directory belonging to the parent theme. That looks a bit strange to me, but it always like that - whether the parent or the child has been activated.

Regards,

Luc

June 19, 2016 at 1:37 pm #918660

lucM-5

Yvette, just one more note. Caching is disabled when being logged on to WordPress. So whenever I switch between parent & child theme, the differences in terms of "translation behavior" are observed instantly (working with the parent, not working with the child).

June 19, 2016 at 1:41 pm #918661

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

I find it interesting that you were not able to get this to work even with the String Tranlsation module.

1 Technical Information on you environment
Could you please provide information about your environment by following thsese steps: http://wpml.org/faq/provide-debug-information-faster-support/

2. Would you be in agreement if we tried to get it working with the module and then you can get it to work with the .mo files?

3. Temporary access to your system
Could you please provide access to your system (wp-admin and ftp) so that I can further investigate this particular problem? The fields to provide this data are included in a private section that I will open for your next response. You can find it above the comments area. The information in this private section is only visible between WPML Support and you.

June 19, 2016 at 3:13 pm #918714

lucM-5

Just one remark: for test purposed, I only copied a limited number of theme files to child theme - including tag.php & search.php. That should allow to check if translation is working.

June 20, 2016 at 6:31 am #918980

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

Can you please recheck the login credentials? I am not able to connect with the ones you posted. The error is that the password is incorrect.

Thanks for advising.

June 20, 2016 at 6:45 am #918984

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

Can you please recheck the login credentials? I am not able to connect with the ones you posted. The error is that the password is incorrect.

Thanks for advising.

June 20, 2016 at 6:46 am #918985

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

Can you please recheck the login credentials? I am not able to connect with the ones you posted. The error is that the password is incorrect.

Thanks for advising.

June 20, 2016 at 6:52 am #918990

lucM-5

Hello Yvette,
from the WP backend, I cannot check the current password but only generate a new one. Can you answer back to me & allow me to provide you a new password using a safe form?

Luc

June 20, 2016 at 7:16 am #919012

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Ok - the private area is now open. Perhaps the last password had a time limit(?). Thanks again.

June 20, 2016 at 9:42 am #919311

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello.

Thank you for the access - it helps a lot to be able to see the system.

I see that you are only using the CMS module and that (as you stated) you are using .mo files to translate your theme strings.

Please note that without the CMS String Translation module, only the user data content will be handled by CMS. The module you have installed adds tables to your database that link together different posts which are to be considered "translations" of each other as well as certain taxonomies. The CMS module does not affect any of your theme string tranlsations.

With this in mind, your original problem/quesiton is not really within the scope of support we can offer as it is reallya theme support issue. However, I did look into the codex for WordPress and I believe your problem is that you should be using the parent theme text-domain for your texts. ( see image)

Here is the relevant wordpress codex: https://developer.wordpress.org/reference/functions/load_child_theme_textdomain/

Note specifically: "...Unlike plugin language files, a name like my_child_theme-de_DE.mo will NOT work. Although plugin language files allow you to specify the text-domain in the filename, this will NOT work with themes and child themes..."

/**
 * Loads the child theme textdomain.
 */
function wpdocs_child_theme_setup() {
    load_child_theme_textdomain( 'my_parent_theme', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'wpdocs_child_theme_setup' );

‘my_parent_theme’ = The name of the Main theme

If you change the text domain to be the parent_theme instead of the child_theme, I believe the strings should then be interpreted correctly.

If you were using String Translations, you would not need to load a child_domain...you would use the parent_domain and then scan all template files for both the parent and child directories.

I also found this information that might be relevant for you:
http://wordpress.stackexchange.com/questions/185999/override-parent-theme-translation-on-child-theme

It talks about the case where you want to "override" the translations form the parent-theme.

I hope this information helps you. I did not do anything to your system except to observe the WPML setup you had.

June 20, 2016 at 10:42 am #919434

lucM-5

Hello Yvette,
Thanks for your reply. I understand it is always a thin line between plugin & theme where the problem might be - but remember that I told you previously that this doesn't even work with string translation activated.

That's why I reinstalled & reactivated string translation. You will see that both lambda_td (for parent theme) & lambda_child_theme will appear in WPML & that strings are being picked up. Nevertheless, the translations are never shown when the child theme is activated. For the time being, I concentrate on 2 strings only (toward the end of the list): RESULTS FOR (after using the search function) and ALL POSTS TAGGED (displayed at the header of any page after selecting any of the tags shown in the footer of my website).

June 20, 2016 at 1:03 pm #919883

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello.

I´ve been doing some tests and I unfortunately made you site inaccessible. This was because I commented out some of your code in the child-theme functions.php and without FTP access I caould not restore it.

Can you please restore this?

I would like to take a snapshot of your system to do some more local testing and so I can send this to a colleague to debug.

What I can tell you is the following experiences that I have had in the past:

1. Without loading a child theme, I have been able to add new text to template files and assigning it a domain of "wpml". This was then successfully translated by String Transation with no problem.

2. I have not seen a new text domain loaded with a child theme. I am sure this is is possible... I have just not seen it before.

So, may I have your pemission to take a snapshot of the system using the Duplicator plugin?
Thanks.

June 20, 2016 at 1:53 pm #920100

lucM-5

Hello Yvette,

The functions.php has been restored & everything works fine again.

So you want to duplicate the entire site to a copy that will further locally test? That's fine with me. When the duplicate has been made, please inform me ASAP. At that moment, I will temporarily block you access to my backend. For the very simple reason, that tomorrow I'm meeting with a client of mine, and I don't want to happen unforeseen things during that meeting. After that meeting, I will grant access again.

Thanks,
Luc