• Resolved mklusak

    (@mklusak)


    Hi, I am using localizable theme/plugin with acoommodation booking process (WP Pages with shortcodes). Its IDs are saved in settings, and for every language there has to be another set of pages, with different IDs (obviously). These options are listed in wpml-config.xml “to translation”, so I should be able set “trasnlation” (= another ID) in String translation tab, but these options are missing!

    <admin-texts>
    	<key name="quitenicebooking">
    		<key name="email_address" /> ... text, OK
    		<key name="phone_number" /> ... text, OK
    		<key name="fax_number" /> ... text, OK
    		<key name="accommodation_page_id" /> ... number, MISSING!
    		<key name="step_1_page_id" /> ... number, MISSING!
    		<key name="step_2_page_id" /> ... number, MISSING!
    		... etc.
    	</key>
    </admin-texts>

    So I think Polylang skips wpml-config.xml terms that are not strings. Is there any solution?

    https://wordpress.org/plugins/polylang/

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

    (@chouby)

    Hi!

    Do you mean they are missing on admin side? Normally Polylang should skip only empty options.

    Thread Starter mklusak

    (@mklusak)

    Hi, thank for replying! Well, yes. There is approx. 20 “admin-texts” items in XML, but in Polylang admin / String translation tab are listed only some of them – those with any string value. Those with only numerical value are missing.

    I am referring to this tutorial for WPML – http://themes.quitenicestuff.com/docs/sohohotelwp/translate-plugin-booking-other.html … I hoped it will be possible with Polylang too.

    Plugin Author Chouby

    (@chouby)

    I successfully translated numeric values. The only case which does not work is when the value is 0.

    Thread Starter mklusak

    (@mklusak)

    Well, I mean those numerical “strings” are not displayed on that tab. So I can’t even to try to translate them.

    XML content: http://imgur.com/OswWzzZ
    String translation tab: http://imgur.com/RaW74GV

    There should be seven another strings between fax_number and currency_unit.

    I searched Polylang source codes and found for example register_string_recursive() (wpml-compat.php).

    protected function register_string_recursive($context, $strings, $options) {
    		foreach ($options as $name => $value) {
    			if (isset($strings[$name])) {
    				if (is_string($value) && $strings[$name] == 1) // !!! -----> is_string($value) ... and $value is number/ID ...
    					pll_register_string($name, $value, $context);
    				elseif (is_array($value) && is_array($strings[$name]))
    					$this->register_string_recursive($context, $strings[$name], $value);
    			}
    		}
    	}

    Those is_string() conditions creates this problem I suppose.

    Plugin Author Chouby

    (@chouby)

    You may be right. Maybe I could not reproduce because in the plugin I used for tests, numeric inputs are kept as strings. Did you make the test if removing the is_string() condition solves your problem?

    Thread Starter mklusak

    (@mklusak)

    Yes, removing is_string() from this conditions did the job – those strings appeared on String translation tab. But there are probably some front-end issues, because even when it was correctly translated in WP admin, nothing changed on front-end … and I gave up searching 🙁

    Plugin Author Chouby

    (@chouby)

    The same in translate_strings_recursive() maybe?

    Thread Starter mklusak

    (@mklusak)

    Yes, it works, but … I don’t want to hardcode those changes to your plugin and disable its later updates 🙁 Have those is_string() checks any special meaning? Will it “break” when removed?

    But there is another issue – the other plugin loads settings on ‘init’ action, and this code

    $this->settings = get_option( 'quitenicebooking' );
    echo "Step 1: " . $this->settings['step_1_page_id'];

    … echoes “Step 1: 5” … but translated value is 213. But this is echoed on the top of the page, before any HTML … plugin has one widget, it is placed in sidebar, and it loads plugins settings again, via $quitenicebooking_settings = get_option('quitenicebooking'); … and now the 5 value is correctly translated to 213!

    I checked that wpml-compat.php translate_strings() function is called even before the first settings load, but returns untranslated values. So I think that when booking plugins loads, Polylang functions works (after is_string() removal), but the setting translation is not available at the moment. But it is available later when the page renders (booking widget loading same settings).

    Do you have any idea what can be wrong now?

    Plugin Author Chouby

    (@chouby)

    1. I will replace the test

    if (is_string($value) && $strings[$name] == 1)

    by

    if ((is_numeric($value) || is_string($value)) && $strings[$name] == 1)

    to definitely allow translating numeric values.

    2. The option is loaded to soon when setting the language from content. Try setting the language from the directory name.

    Thread Starter mklusak

    (@mklusak)

    1. Yay! Thank you 🙂

    2. Yes! It’s my default choice everytime (language by directory), and I know I was setting it this time too. But now I see the “language by content” is set. Setting language from directory (and those changes in source code) solved my issue.

    Can I ask when the change in source code will by public?

    Plugin Author Chouby

    (@chouby)

    That’s now in the development version (1.5.5.3).
    https://downloads.wordpress.org/plugin/polylang.zip

    Thread Starter mklusak

    (@mklusak)

    Upgrade solved everything! Thank you very much! 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Wpml-config.xml strings skipped when numbers (IDs)’ is closed to new replies.