BazingaJsTranslationBundle icon indicating copy to clipboard operation
BazingaJsTranslationBundle copied to clipboard

Messages in ICU format not dumped

Open sweedheart opened this issue 3 years ago • 7 comments

I have a "messages+intl-icu.en.yaml" file in default translation folder. When running the dump command, the messages domain is not dumped at all. When I remove the "+intl-icu" extension from the file-name, the domain ist dumped, but is obviously not working due to the ICU format used inside the file.

Probably caused by a continue in TranslationDumper: // e.g.: skip "messages+intl-icu" if "messages" exists. They will get merged after.

As there is nothing done afterwards, the skipped domains won´t get dumped. Seems like dumping ICU translations are only working when there are already other translations in the same non-ICU domain.

validators domain ist dumped correctly when using ICU format, as there are already translations in some bundle for that domain.

sweedheart avatar Jan 03 '21 10:01 sweedheart

I fixed this by adding another empty messages.yaml file without the +intl-icu suffix. Maybe this works for you as well.

aheidelberg avatar Jan 27 '21 13:01 aheidelberg

I am running into the same issue, is there any way to solve this?

Schyzophrenic avatar Jun 05 '21 20:06 Schyzophrenic

Hi, any update regarding this issue?

tpatartmajeur avatar Aug 25 '21 09:08 tpatartmajeur

Upgrading from v3 to v4 broke this as well, on our project.

It seems like the following commit introduced the breaking change: https://github.com/willdurand/BazingaJsTranslationBundle/commit/43a51cf1fa2adc4c7bb985af8c9ebc414eea04a0 (Especially changes in file Dumper/TranslationDumper.php)

Because it's now the "cleaned" domain that is looked up in "$activeDomains", my configuration entry "mass_updates+intl-icu" (in bazinga_js_translation.yaml::bazinga_js_translation.active_domains) doesn't get picked up anymore.

So I thought maybe the right approach now is to add the "cleaned up" entry in the bazinga_js_translation.yaml configuration file: "mass_updates" only. But if doing so makes the domain to be picked up by TranslationDumper::getTranslations, it still gets removed in the following section by TranslationDumper::dumpTranslationsPerDomain:

                if ($domain !== $cleanedDomain && !in_array($cleanedDomain, $domains, true)) {
                    // e.g.: skip "messages+intl-icu" if "messages" exists. They will get merged after.
                    continue;
                }

~~Considering what the comment says: "skip "messages+intl-icu" if "messages" exists", I'm wondering if the if test shouldn't be as follows instead (removed !): [deleted code]~~

EDIT: Turns out $domains does NOT contain domains, but translations as values, and domains as keys. So the test to be done is probably more something like:

if ($domain !== $cleanedDomain && !isset($domains[$cleanedDomain])) {

But I do not really understand why "uncleaned" domains get ignored in the first place, to be honest. So there's more to it.

pacproduct avatar Nov 22 '21 14:11 pacproduct

I fixed this by adding another empty messages.yaml file without the +intl-icu suffix. Maybe this works for you as well.

It does work but in my case I had to:

  • Add an empty file without the suffix next to the suffixed file.
  • Add this new file in bazinga_js_translation.yaml::bazinga_js_translation.active_domains
  • Adapt my Javascript so it loads translations from the file without suffix, as it now gets generated without it.

pacproduct avatar Nov 22 '21 15:11 pacproduct

Any up about this issue ? @stof @monteiro

NicolasJourdan avatar Feb 13 '24 14:02 NicolasJourdan