Skip to content

[Validator] Make it explicit when English translation differs from its resource name #53507

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 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 19 additions & 7 deletions .github/sync-translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
$metadata = $messages->getMetadata($source, $domain);

$translation->setAttribute('id', $metadata['id']);
if (isset($metadata['resname'])) {
$translation->setAttribute('resname', $metadata['resname']);
}

$s = $translation->appendChild($dom->createElement('source'));
$s->appendChild($dom->createTextNode($source));
Expand Down Expand Up @@ -64,23 +67,32 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
$dir = __DIR__.'/../src/Symfony/Component/'.$component.'/Resources/translations';

$enCatalogue = (new XliffFileLoader())->load($dir.'/'.$domain.'.en.xlf', 'en', $domain);
file_put_contents($dir.'/'.$domain.'.en.xlf', dumpXliff1('en', $enCatalogue, $domain));

$finder = new Finder();

foreach ($finder->files()->in($dir)->name('*.xlf') as $file) {
$locale = substr($file->getBasename(), 1 + strlen($domain), -4);

if ('en' === $locale) {
continue;
}

$catalogue = (new XliffFileLoader())->load($file, $locale, $domain);
$localeCatalogue = new MessageCatalogue($locale);

foreach ($enCatalogue->all($domain) as $id => $translation) {
foreach ($enCatalogue->all($domain) as $resname => $source) {
$metadata = [];
if ($catalogue->defines($id, $domain)) {
$translation = $catalogue->get($id, $domain);
$metadata = $catalogue->getMetadata($id, $domain);
if ($catalogue->defines($resname, $domain)) {
$translation = $catalogue->get($resname, $domain);
$metadata = $catalogue->getMetadata($resname, $domain);
}
$metadata['id'] = $enCatalogue->getMetadata($resname, $domain)['id'];
if ($resname !== $source) {
$metadata['resname'] = $resname;
}
$metadata['id'] = $enCatalogue->getMetadata($id, $domain)['id'];
$localeCatalogue->set($id, $translation, $domain);
$localeCatalogue->setMetadata($id, $metadata, $domain);
$localeCatalogue->set($source, $translation, $domain);
$localeCatalogue->setMetadata($source, $metadata, $domain);
}

file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
<source>This file is not a valid image.</source>
<target>Hierdie lêer is nie 'n geldige beeld nie.</target>
</trans-unit>
<trans-unit id="37">
<source>This is not a valid IP address.</source>
<trans-unit id="37" resname="This is not a valid IP address.">
<source>This value is not a valid IP address.</source>
<target state="needs-review-translation">Hierdie waarde is nie 'n geldige IP-adres nie.</target>
</trans-unit>
<trans-unit id="38">
Expand Down Expand Up @@ -190,9 +190,9 @@
<source>No file was uploaded.</source>
<target>Geen lêer is opgelaai nie.</target>
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>Geen tydelike lêer is ingestel in php.ini nie.</target>
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
<target state="needs-review-translation">Geen tydelike gids is in php.ini opgestel nie, of die opgestelde gids bestaan nie.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down Expand Up @@ -222,8 +222,8 @@
<source>Unsupported card type or invalid card number.</source>
<target>Nie-ondersteunde tipe kaart of ongeldige kredietkaart nommer.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
<source>This value is not a valid International Bank Account Number (IBAN).</source>
<target state="needs-review-translation">Hierdie waarde is nie 'n geldige Internasionale Bankrekeningnommer (IBAN) nie.</target>
</trans-unit>
<trans-unit id="60">
Expand Down Expand Up @@ -310,16 +310,16 @@
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Die waarde stem nie ooreen met die verwagte {{ charset }} karakterstel nie.</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
<source>This value is not a valid Business Identifier Code (BIC).</source>
<target state="needs-review-translation">Hierdie waarde is nie 'n geldige Besigheid Identifiseerder Kode (BIC) nie.</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>Fout</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<trans-unit id="83" resname="This is not a valid UUID.">
<source>This value is not a valid UUID.</source>
<target state="needs-review-translation">Hierdie waarde is nie 'n geldige UUID nie.</target>
</trans-unit>
<trans-unit id="84">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
<source>This file is not a valid image.</source>
<target>هذا الملف ليس صورة صحيحة.</target>
</trans-unit>
<trans-unit id="37">
<source>This is not a valid IP address.</source>
<trans-unit id="37" resname="This is not a valid IP address.">
<source>This value is not a valid IP address.</source>
<target state="needs-review-translation">هذه القيمة ليست عنوان IP صالحًا.</target>
</trans-unit>
<trans-unit id="38">
Expand Down Expand Up @@ -190,9 +190,9 @@
<source>No file was uploaded.</source>
<target>لم يتم ارسال اى ملف.</target>
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>لم يتم تهيئة حافظة مؤقتة فى ملف php.ini.</target>
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
<target state="needs-review-translation">لم يتم تكوين مجلد مؤقت في ملف php.ini، أو المجلد المعد لا يوجد.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down Expand Up @@ -222,8 +222,8 @@
<source>Unsupported card type or invalid card number.</source>
<target>نوع البطاقه غير مدعوم او الرقم غير صحيح.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
<source>This value is not a valid International Bank Account Number (IBAN).</source>
<target state="needs-review-translation">هذه القيمة ليست رقم حساب بنكي دولي (IBAN) صالحًا.</target>
</trans-unit>
<trans-unit id="60">
Expand Down Expand Up @@ -310,16 +310,16 @@
<source>This value does not match the expected {{ charset }} charset.</source>
<target>هذه القيمة غير متطابقة مع صيغة التحويل {{ charset }}.</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
<source>This value is not a valid Business Identifier Code (BIC).</source>
<target state="needs-review-translation">هذه القيمة ليست رمز معرف الأعمال (BIC) صالحًا.</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>خطأ</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<trans-unit id="83" resname="This is not a valid UUID.">
<source>This value is not a valid UUID.</source>
<target state="needs-review-translation">هذه القيمة ليست UUID صالحًا.</target>
</trans-unit>
<trans-unit id="84">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
<source>This file is not a valid image.</source>
<target>Bu fayl düzgün bir şəkil deyil.</target>
</trans-unit>
<trans-unit id="37">
<source>This is not a valid IP address.</source>
<trans-unit id="37" resname="This is not a valid IP address.">
<source>This value is not a valid IP address.</source>
<target state="needs-review-translation">Bu dəyər etibarlı bir IP ünvanı deyil.</target>
</trans-unit>
<trans-unit id="38">
Expand Down Expand Up @@ -190,9 +190,9 @@
<source>No file was uploaded.</source>
<target>Fayl yüklənmədi.</target>
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>php.ini'də müvəqqəti qovluq quraşdırılmayıb.</target>
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
<target state="needs-review-translation">php.ini-də müvəqqəti qovluq quraşdırılmayıb, və ya quraşdırılmış qovluq mövcud deyil.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down Expand Up @@ -222,8 +222,8 @@
<source>Unsupported card type or invalid card number.</source>
<target>Dəstəklənməyən kart tipi və ya yanlış kart nömrəsi.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
<source>This value is not a valid International Bank Account Number (IBAN).</source>
<target state="needs-review-translation">Bu dəyər etibarlı bir Beynəlxalq Bank Hesab Nömrəsi (IBAN) deyil.</target>
</trans-unit>
<trans-unit id="60">
Expand Down Expand Up @@ -310,16 +310,16 @@
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Bu dəyər gözlənilən {{ charset }} simvol cədvəli ilə uyğun gəlmir.</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
<source>This value is not a valid Business Identifier Code (BIC).</source>
<target state="needs-review-translation">Bu dəyər etibarlı bir Biznes Təyinat Kodu (BIC) deyil.</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>Xəta</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<trans-unit id="83" resname="This is not a valid UUID.">
<source>This value is not a valid UUID.</source>
<target state="needs-review-translation">Bu dəyər etibarlı bir UUID deyil.</target>
</trans-unit>
<trans-unit id="84">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
<source>This file is not a valid image.</source>
<target>Гэты файл не з'яўляецца сапраўднай выявай.</target>
</trans-unit>
<trans-unit id="37">
<source>This is not a valid IP address.</source>
<trans-unit id="37" resname="This is not a valid IP address.">
<source>This value is not a valid IP address.</source>
<target state="needs-review-translation">Гэта значэнне не з'яўляецца сапраўдным IP-адрасам.</target>
</trans-unit>
<trans-unit id="38">
Expand Down Expand Up @@ -190,8 +190,8 @@
<source>No file was uploaded.</source>
<target>Файл не быў запампаваны.</target>
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
<target>У php.ini не была налажана часовая папка, або часовая папка не існуе.</target>
</trans-unit>
<trans-unit id="52">
Expand Down Expand Up @@ -222,8 +222,8 @@
<source>Unsupported card type or invalid card number.</source>
<target>Тып карты не падтрымліваецца або несапраўдны нумар карты.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
<source>This value is not a valid International Bank Account Number (IBAN).</source>
<target state="needs-review-translation">Гэта значэнне не з'яўляецца сапраўдным міжнародным нумарам банкаўскага рахунку (IBAN).</target>
</trans-unit>
<trans-unit id="60">
Expand Down Expand Up @@ -310,16 +310,16 @@
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Гэта значэнне не супадае з чаканай {{ charset }} кадыроўкай.</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
<source>This value is not a valid Business Identifier Code (BIC).</source>
<target state="needs-review-translation">Гэта значэнне не з'яўляецца сапраўдным кодам ідэнтыфікацыі бізнесу (BIC).</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>Памылка</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<trans-unit id="83" resname="This is not a valid UUID.">
<source>This value is not a valid UUID.</source>
<target state="needs-review-translation">Гэта значэнне не з'яўляецца сапраўдным UUID.</target>
</trans-unit>
<trans-unit id="84">
Expand Down
Loading