Skip to content

Bundle does not work properly with new Intl ICU translations #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jan 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b020360
Remove both "normal" and ICU domain from messages set
snpy Aug 24, 2021
d4c78c2
Add new configuration for new message format
snpy Aug 24, 2021
3952ec8
Add new field and getter based on recently added new config option
snpy Aug 24, 2021
bdad565
Make sure importer is ICU format aware
snpy Aug 24, 2021
c7284ed
Make sure new_message_format configuration is defined
snpy Aug 24, 2021
ab6631d
Pass to converter new_message_format configuration
snpy Aug 24, 2021
bd68a10
Make sure importer is aware of ICU domain format
snpy Aug 24, 2021
6429fb4
Let code "breath" a bit
snpy Aug 24, 2021
ef9c691
Make sure we're always aware of ICU domain
snpy Aug 24, 2021
af20898
Make sure we're aware of 3 different message domains
snpy Aug 24, 2021
04a1f1e
Persist PHP CS Fixer changes
snpy Aug 30, 2021
0b1317a
Merge pull request #2 from php-translation/master
snpy Nov 24, 2022
c040dab
Remove both "normal" and ICU domain from messages set
snpy Aug 24, 2021
1e88a37
Add new configuration for new message format
snpy Aug 24, 2021
a383c24
Add new field and getter based on recently added new config option
snpy Aug 24, 2021
5b321e1
Make sure importer is ICU format aware
snpy Nov 24, 2022
a39113e
Make sure new_message_format configuration is defined
snpy Aug 24, 2021
592b8f2
Pass to converter new_message_format configuration
snpy Aug 24, 2021
c3dbe3b
Make sure importer is aware of ICU domain format
snpy Aug 24, 2021
ee0cc66
Let code "breath" a bit
snpy Aug 24, 2021
d3b44d9
Make sure we're always aware of ICU domain
snpy Nov 24, 2022
1c7da76
Make sure we're aware of 3 different message domains
snpy Aug 24, 2021
8802b6f
Persist PHP CS Fixer changes
snpy Aug 30, 2021
b4b4f5a
Merge branch 'handle-icu-domain' of github.com:kram-soft/symfony-bund…
snpy Nov 24, 2022
f2e80e0
Apply PHP CS fixer automated fix
snpy Nov 24, 2022
bc9bd5f
Fix main PHPUnit issue
snpy Nov 24, 2022
1e099ec
Fix catalogue counter
snpy Nov 24, 2022
4116221
Make assertion more wordy
snpy Nov 24, 2022
cabf00a
Update configuration to have passing tests
snpy Nov 24, 2022
0c31b96
Merge pull request #3 from php-translation/master
snpy Jan 11, 2023
202af61
Merge branch 'master' into handle-icu-domain
snpy Jan 11, 2023
4c52eec
Apply PHP-CS-Fixer suggestion
snpy Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make sure importer is aware of ICU domain format
Because of MessageCatalogue interface limitation we're using NSA to
access raw messages data.
Additionally because defines() method uses isset() were force to check
raw messages data directly to check if key exits (translations from
source collection are all set to NULL).

#300
  • Loading branch information
snpy committed Aug 24, 2021
commit bd68a10bfb366a446c0e53aaa0a4941ef7e424d0
24 changes: 16 additions & 8 deletions Service/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
$this->convertSourceLocationsToMessages($target, $sourceCollection, $catalogue);

// Remove all SourceLocation and State form catalogue.
foreach ($catalogue->getDomains() as $domain) {
foreach ($catalogue->all($domain) as $key => $translation) {
foreach (NSA::getProperty($catalogue, 'messages') as $domain => $translations) {
foreach ($translations as $key => $translation) {
$meta = $this->getMetadata($catalogue, $key, $domain);
$meta->removeAllInCategory('file-source');
$meta->removeAllInCategory('state');
Expand All @@ -91,28 +91,36 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
$result = $merge->getResult();
$domains = $merge->getDomains();

$resultMessages = NSA::getProperty($result, 'messages');

// Mark new messages as new/obsolete
foreach ($domains as $domain) {
$intlDomain = $domain . '+intl-icu' /* MessageCatalogueInterface::INTL_DOMAIN_SUFFIX */;

foreach ($merge->getNewMessages($domain) as $key => $translation) {
$meta = $this->getMetadata($result, $key, $domain);
$messageDomain = array_key_exists($key, $resultMessages[$intlDomain] ?? []) ? $intlDomain : $domain;

$meta = $this->getMetadata($result, $key, $messageDomain);
$meta->setState('new');
$this->setMetadata($result, $key, $domain, $meta);
$this->setMetadata($result, $key, $messageDomain, $meta);

// Add custom translations that we found in the source
if (null === $translation) {
if (null !== $newTranslation = $meta->getTranslation()) {
$result->set($key, $newTranslation, $domain);
$result->set($key, $newTranslation, $messageDomain);
// We do not want "translation" key stored anywhere.
$meta->removeAllInCategory('translation');
} elseif (null !== ($newTranslation = $meta->getDesc()) && $catalogue->getLocale() === $this->defaultLocale) {
$result->set($key, $newTranslation, $domain);
$result->set($key, $newTranslation, $messageDomain);
}
}
}
foreach ($merge->getObsoleteMessages($domain) as $key => $translation) {
$meta = $this->getMetadata($result, $key, $domain);
$messageDomain = array_key_exists($key, $resultMessages[$intlDomain] ?? []) ? $intlDomain : $domain;

$meta = $this->getMetadata($result, $key, $messageDomain);
$meta->setState('obsolete');
$this->setMetadata($result, $key, $domain, $meta);
$this->setMetadata($result, $key, $messageDomain, $meta);
}
}
$results[] = $result;
Expand Down