willdurand / BazingaJsTranslationBundle

A pretty nice way to expose your Symfony translation messages to your client applications.
MIT License
572 stars 178 forks source link

Messages in ICU format not dumped #312

Open sweedheart opened 3 years ago

sweedheart commented 3 years ago

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.

aheidelberg commented 3 years ago

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

Schyzophrenic commented 3 years ago

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

tpatartmajeur commented 2 years ago

Hi, any update regarding this issue?

pacproduct commented 2 years ago

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 commented 2 years ago

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:

NicolasJourdan commented 4 months ago

Any up about this issue ? @stof @monteiro

PrezentInternet commented 1 month ago

It appears this is still a problem in 6.0