Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why strings don't appear in "String translation" of WPML?

Tags:

wordpress

wpml

I have in my php files string like this:

<?php
__('My string A', 'a_theme');
_e('My string B', 'a_theme');
?>

and there are not appearing in "String translation" .

I have also bought and installed this theme: http://preview.ait-themes.com/index.php?bartype=desktop&theme=touroperator and strings from that theme aren't also appearing in "Strings translation" of WPML.

This is one example of string which was already in theme when I installed it:

<input type="text" id="dir-searchinput-location" class="dir-searchinput-select" placeholder="{__ 'Destination'}">

Is there some extra configuration which I need to do or something else?

Thanks for help

like image 918
iWizard Avatar asked Nov 10 '13 12:11

iWizard


People also ask

What is a string translation?

WPML string translation refers to translating any content that falls outside the WordPress editor. When you use WPML, you can easily translate post content by essentially creating a “duplicate” version of each piece of content in a new language (or by using WPML's new Advanced Translation Editor).

How do I translate custom fields in WPML?

To be able to translate custom fields, you need to set them as “translatable” in WPML. To do this, go to WPML → Settings and scroll to the Custom Field Translation section. There are four options to choose from: Don't translate – the field is not available for translation.


1 Answers

To get strings to appear in String Translation, you first need to go to Theme and plugins localization. Scroll down to the Strings in the theme section and then click the Scan the theme for strings button. WPML will then detect any unregistered or newly added strings that are properly formatted for localization.

If it works, you'll see your theme a-theme listed in the Domain column and the number of detected strings in the Count column. Clicking the View strings that need translation button will take you to String Translation. If any of the strings aren't properly formatted for localization, the count won't be updated.

If you update existing strings or add new ones, you'll need to rescan before WPML adds them to String Translation.

The formatting in your first example looks OK and WPML should detect the strings, but in the second example, you haven't declared a domain. Without a domain, WPML won't pick up the string.

The correct format is

__('Your string', 'yourDomain') or _e('Your string', 'yourDomain')

In this case, the domain should be the name of your theme, 'a_theme'.

like image 164
user2895499 Avatar answered Sep 28 '22 13:09

user2895499