Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the use of wpml-config.xml if you have String Translation?

What is exactly the usage of wpml-config.xml file in WPML? Especially if I have translation management and string translation add-ons enabled? With those I just scan my theme, the plugin finds all the translatable strings, and I can just translate them. And I am duplicating pages etc when translating them.

So what exactly is the purpose of that .xml file? I'm kinda puzzled :\

EDUCATED EDIT

After working a bit more with wpml, I also found out that if you create, say, a copyright text that will be shown in the footer in your customizer, then the only way to translate that text with wpml, is to use wpml-config.xml file. So basically for any text based input field in your theme, you need to specify to wpml that it can be a translatable text. And you'd do it like this:

<wpml-config>
    <admin-texts>
        <key name="blogname" />
        <key name="blogdescription" />
        <key name="theme_mods_language_textdomain">
            <key name="copyright" />
        </key>
    </admin-texts>
</wpml-config>

Where you need to specify the language textdomain (or the theme name, not 100% sure on this one yet). Inside you target the settings name that has the input field ('type' => 'text' fields).

I recon that the same could be done with the metaboxes that output something on the frontend, but you'd need a different tag in your .xml.

like image 266
dingo_d Avatar asked Oct 19 '22 20:10

dingo_d


1 Answers

Here is my little bit detailed information, let say you created custom plugin and make it compatible with wpml!, so you created po files inorder to translate labels and it is something like below and it will work accordingly,

<?php _e('Hi Fresher','your_text_domain');?> 

but if you tried the same thing as something like

<?php _e(get_option('testmyname','your_text_domain'));?> //testmyname contain Hi Fresher

Is work with normal translation? and you cannot make it wpml compatible. In order to overcome this problem wpml already provide xml file in order to fulfill translate ready.

In this case you can simply use it as and you have to enter few more information in wpml-config.xml file, is should be placed in root folder of anything (theme folder/plugin folder). create wpml-config.xml file and do this something

<wpml-config>
    <admin-texts>
        <key name="blogname" />
    </admin-texts>
</wpml-config>

the above code is in wpml-config.xml file and it should be placed in root folder of your theme, i tried myself for testing purpose here is the result,

Screenshot is for before translation, after translation and french output

Before Translation and wpml-config.xml file listed in string translation of wpml Before Translation

After Translate your custom Text After Translation

Sample Output that i changed to french based on dropdown Sample Output

Hope it helps :)

Thanks.

like image 199
Vignesh Pichamani Avatar answered Oct 22 '22 19:10

Vignesh Pichamani