• Resolved Artistiana

    (@ci-media)


    Today we made a full backup of our live, 3 languages website, and restored it on the local development server. The translations did not restore, and, as there are quite a few, it is rather difficult and time-consuming to re-enter them manually.

    The 3 defined languages are there, with their order correctly set; that is the first tab from the settings page of the plugin.

    The “Settings” (third) tab is also correct (default language, URL modifications, synchronizations etc.).

    But the “Strings translations” (second) tab is wrong. The strings are there all right, even the ones we registered in functions.php and those belonging to the plugins and widgets we use, but they are not translated; the 3 versions of the strings are all in the default language.

    We carefully read this thread: https://www.ads-software.com/support/topic/exporting-full-wp-mysql-db-losing-polylang-strings-translations but could not manage to get back our translations.

    We noticed that the tabs 1 and 3 (“Languages” and “Settings”) are saved in the options table, but the strings translations are in the posts table. We tried to manually update the 3 records in the local database with the content of the corresponding records in the live database. No result. A SELECT from the database shows that the records are correct, that is each polylang_mo_xx has the right translation, but in the WordPress admin console the 3 versions of the same string display the default value. Of course, the front-end is all wrong.

    We thought the backup/ restore process would be a straightforward one, but Polylang behaved so oddly!

    Please analyse the problem and let us know how to avoid or fix it, since this is the second time a thread is open on this topic.

    Our site uses WP 4.01 and Polylang 1.6.2.

    https://www.ads-software.com/plugins/polylang/

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

    (@chouby)

    Hi!

    each polylang_mo_xx has the right translation

    Could you give the exact post_title of your 3 rows ?

    in wp_term_taxonomy, could you give the term_id of your 3 languages (taxonomy: ‘language’) ?

    in wp_options, could you paste the value of the option ‘_transient_pll_languages_list’ ?

    Thread Starter Artistiana

    (@ci-media)

    Hello,

    Thank you for the quick answer, here are the data:

    1. wp_posts post_title:
    polylang_mo_20, polylang_mo_22, polylang_mo_35

    2. wp_taxonomy term_id:
    20, 22, 35

    3. wp_options _transient_pll_languages_list:
    a:3:{i:0;O:12:”PLL_Language”:20:{s:7:”term_id”;i:20;s:4:”name”;s:9:”Fran?ais”;s:4:”slug”;s:2:”fr”;s:10:”term_group”;s:1:”0″;s:16:”term_taxonomy_id”;i:21;s:8:”taxonomy”;s:8:”language”;s:11:”description”;s:5:”fr_FR”;s:6:”parent”;s:1:”0″;s:5:”count”;i:148;s:10:”tl_term_id”;i:21;s:19:”tl_term_taxonomy_id”;i:22;s:8:”tl_count”;i:18;s:6:”locale”;R:9;s:6:”is_rtl”;s:1:”0″;s:8:”flag_url”;N;s:4:”flag”;N;s:8:”home_url”;s:36:”https://127.0.0.1:8080/cimediapro/fr/”;s:10:”search_url”;s:36:”https://127.0.0.1:8080/cimediapro/fr/”;s:4:”host”;N;s:5:”mo_id”;s:4:”1059″;}i:1;O:12:”PLL_Language”:20:{s:7:”term_id”;i:22;s:4:”name”;s:7:”English”;s:4:”slug”;s:2:”en”;s:10:”term_group”;s:1:”1″;s:16:”term_taxonomy_id”;i:23;s:8:”taxonomy”;s:8:”language”;s:11:”description”;s:5:”en_US”;s:6:”parent”;s:1:”0″;s:5:”count”;i:113;s:10:”tl_term_id”;i:23;s:19:”tl_term_taxonomy_id”;i:24;s:8:”tl_count”;i:16;s:6:”locale”;R:29;s:6:”is_rtl”;s:1:”0″;s:8:”flag_url”;N;s:4:”flag”;N;s:8:”home_url”;s:36:”https://127.0.0.1:8080/cimediapro/en/”;s:10:”search_url”;s:36:”https://127.0.0.1:8080/cimediapro/en/”;s:4:”host”;N;s:5:”mo_id”;s:4:”1060″;}i:2;O:12:”PLL_Language”:20:{s:7:”term_id”;i:35;s:4:”name”;s:8:”Roman?”;s:4:”slug”;s:2:”ro”;s:10:”term_group”;s:1:”2″;s:16:”term_taxonomy_id”;i:36;s:8:”taxonomy”;s:8:”language”;s:11:”description”;s:5:”ro_RO”;s:6:”parent”;s:1:”0″;s:5:”count”;i:112;s:10:”tl_term_id”;i:36;s:19:”tl_term_taxonomy_id”;i:37;s:8:”tl_count”;i:17;s:6:”locale”;R:49;s:6:”is_rtl”;s:1:”0″;s:8:”flag_url”;N;s:4:”flag”;N;s:8:”home_url”;s:36:”https://127.0.0.1:8080/cimediapro/ro/”;s:10:”search_url”;s:36:”https://127.0.0.1:8080/cimediapro/ro/”;s:4:”host”;N;s:5:”mo_id”;s:4:”1078″;}}

    In the live database, instead of https://127.0.0.1:8080/cimediapro/ is https://www.cimediapro.com.

    I hope this is helpful to find where the problem is.

    Plugin Author Chouby

    (@chouby)

    Are your post ID for your polylang_mo_xx 1059, 1060 and 1078?

    Did you manually changed the https://www.cimediapro.com/ to https://127.0.0.1:8080/cimediapro/ in _transient_pll_languages_list?

    Thread Starter Artistiana

    (@ci-media)

    1. Yes, the post IDs are 1059, 1060 and 1078 respectively.

    2. Yes, we manually changed the live site URL to the local URL. After we noticed the translations issue, we made another try at restoring the database: this time we replaced (in the original backup SQL script) the URLs in all occurrences except for the polylang_mo_xx records and rerun the script. This didn’t work either.

    Plugin Author Chouby

    (@chouby)

    Could you try to delete the option _transient_pll_languages_list?

    Thread Starter Artistiana

    (@ci-media)

    All right, I deleted the option, and refreshed the Polylang settings page, but nothing changed. The strings are there, with their FR, EN and RO versions holding identical values, as before.

    Plugin Author Chouby

    (@chouby)

    Hum…

    The only way I see to try to solve your issue is to debug it:

    Can you edit wp-config.php and replace:
    define('WP_DEBUG', false);
    by

    define('WP_DEBUG', true);
    define('SCRIPT_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);

    then edit polylang/include.mo.php near line 57 and replace:

    public function import_from_db($lang) {
    	if (!empty($lang->mo_id)) {
    		$post = get_post($lang->mo_id, OBJECT);
    		$strings = unserialize($post->post_content);
    		if (is_array($strings)) {
    			foreach ($strings as $msg)
    				$this->add_entry($this->make_entry($msg[0], $msg[1]));
    		}
    	}
    }

    by

    public function import_from_db($lang) {
    	error_log(print_r($lang, true));
    	if (!empty($lang->mo_id)) {
    		$post = get_post($lang->mo_id, OBJECT);
    		error_log(var_export($post, true));
    		$strings = unserialize($post->post_content);
    		error_log(print_r($strings, true));
    		if (is_array($strings)) {
    			foreach ($strings as $msg)
    				$this->add_entry($this->make_entry($msg[0], $msg[1]));
    		}
    	}
    }

    then visit *one* time the strings translation panel.
    This will create a file wp-content/debug.log
    This may produce a quite big output if you have a lot of translations so please don’t paste the content here but give me a link (you can use pastebin for example).

    Thread Starter Artistiana

    (@ci-media)

    Hello,

    Here is the link: debug log .

    Thank you so much for going that deep into our problem, we really appreciate it!

    Plugin Author Chouby

    (@chouby)

    Hi!

    I believe that the polylang_mo_xx content has been corrupted. In post_content, you replaced https://www.cimediapro.com/ by https://127.0.0.1:8080/cimediapro/ but since it is a serialized string, the data has been corrupted. Try to revert the replacement in the post_content of these 3 posts.

    Thread Starter Artistiana

    (@ci-media)

    Hi,

    I replaced in wp_posts the local URL with the remote one, but the problem persists.

    Here is the debug log and the concerned posts in CSV format.

    Thread Starter Artistiana

    (@ci-media)

    Well, what do you know! I updated from WordPress 4.01 to 4.1 (I was delaying this operation until the translations issue was solved, but in the end I decided to update, just in case).

    And after the WP update was completed, it prompted me to update the Automattic themes translations, TwentyFifteen & co. And when this update was done, MY translations appeared in the Polylang settings panel as they should have been from the very beginning.

    Then, just in order to make sure that the WP update completely solved the problem, I rerun the database restore script. This time the restore went without any issue, the translation strings are there and the local site is finally all right.

    Conclusion: the DB restore under WP 4.01 caused the translation to be lost; upgrading to WP 4.1 solved the problem.

    A big thank you to the plugin author for the quality of the support he provided to us!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Strings translations are lost after restore’ is closed to new replies.