Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Javascript translations (admin_html_tags) leave empty fields #175

Open
4000degrees opened this issue Dec 3, 2020 · 0 comments
Open

Javascript translations (admin_html_tags) leave empty fields #175

4000degrees opened this issue Dec 3, 2020 · 0 comments

Comments

@4000degrees
Copy link

4000degrees commented Dec 3, 2020

When admin_html_tags is used the selected fields become empty.

This part of code doesn't work:
wp-multilang/assets/scripts/translator.js:52

    blocks.forEach(function(block, index) {
      if (index % 2 === 1) {
        lang = block;
      } else if (!!results[lang]) {
        results[lang] += block.trim();
      }
    });

The first problem is that language tags don't get stripped. In blocks array they look like "[:en]" not just "en". So in the else part if is never true because "[:en]" is compared to "en".

The second problem is !!results[lang] which is never true also. It should be "lang in results".

This is working:

    blocks.forEach(function(block, index) {
      if (index % 2 === 1) {
        lang = block.replace(/\[|\]|:/g,'');
      } else if (lang in results) {
        results[lang] += block.trim();
      }
    });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant