• Resolved alexisragot

    (@alexisragot)


    Hi,

    On my WordPress, I use wpml-config.xml file to translate options.

    
    <wpml-config>
      <admin-texts>
        [...]
        <key name="my_plugin_1_settings">
        	<key name="my_plugin_1_custom_text"></key>
        </key>
        [...]
        <key name="my_plugin_2_settings">
        	<key name="my_plugin_2_other_text"></key>
        </key>
        [...]
      </admin-texts>
    </wpml-config>
    

    As you can see, I have 2 plugins, and each one has its own options. The fact is that it exists an option in each of those 2 plugins that has the same string as value. For example “Lorem ipsum”.

    But in “Strings Translations” list, I can only see the string for the option my_plugin_2_other_text. And on my website, only this string appears translated.

    I took a look into your code and I see that in pll_register_string function (triggered on parsing the wpml-config.xml file), you use the md5 of the string as a key in the associative array that stores the registered string : here

    And if I trace it, I can see that the registration of the first option string my_plugin_1_custom_text is overrided by the registration of the second option string my_plugin_2_other_text (because they have the same string = the same md5 = the same array key). And at the end, only the registration of the second string is available.

    How can I prevent this, without changing the options values?

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    You can’t. Currently you can’t have different translations depending on the context. However, you can change the option value, for example “Lorem ipsum 2” for your second option and overwrite this “Lorem ipsum 2” by “Lorem ipsum” in the main language (as the strings translations allow you to translate the strings but also to overwrite the string in the source language).

    Thread Starter alexisragot

    (@alexisragot)

    Hi,

    Thank you for the solution. I didn’t understand that you can translate + overwrite strings in the source language.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with pll_register_string and same string to translate’ is closed to new replies.