6

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.

dingo_d
  • 11,160
  • 11
  • 73
  • 132
  • can you able to translate with wpml like get_option('something'); or any text which has been saved in db/options table ? Let say you echo some of get_option value over wp_head hook, and visitors for your site going to change the language as from english to french in this case whatever you tried echo get_option('test'); will it change? or if you change _e(get_option('test'),'yourtextdomain'); will it work with changing different language? no right, For that reason only we are using wpml-config.xml http://wpml.org/documentation/support/language-configuration-files/ – Vignesh Pichamani Dec 22 '14 at 13:01
  • I tried searching my wp_options table in database (using phpmyadmin) to see what options I should put in, but I'm not sure what to put in. Also how to find all strings to put in .xml file? In the link you posted it says that in Multilingual content setup I have all info I need. So I should just copy those to .xml file? – dingo_d Dec 22 '14 at 13:35
  • Let say you have been using custom made plugin with custom post type or get_option or custom table in this scenario it will help with using xml file because i too use it for my project, may be you haven't tried custom stuff like function or any in this case it may not required – Vignesh Pichamani Dec 22 '14 at 13:39
  • So I should put in there, under key with values like blogname or blogdescription? Because some options are just 0 or 1 (true or false). And if I tried with and without String translation add on, and without I couldn't see anything from .xml file. – dingo_d Dec 22 '14 at 13:51

1 Answers1

4

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.

Vignesh Pichamani
  • 7,950
  • 22
  • 77
  • 115
  • I just realized that I only had 25 items shown in my wp_option table and when I put 500, there were many many more. I'll go through that and write down the ones that can be translatable. Thanks for the explanation! – dingo_d Dec 23 '14 at 07:22