`testLocalizedData()` failing after recent strings update
In CI, the test testLocalizedData()
has started failing consistently. I've done some hunting and may have an explanation (but don't know the next step).
The Test: testLocalizedData()
generates the SQL data-set in two locales. It spot-checks the data for a common string that should usually be translated. Specifically, New Organization
is a link in the default menu. It's translated as Neue Organisation
(de_DE
) or Nouvelle organisation
(fr_FR
).
Compare: The test passes on my laptop but not in CI. My laptop has older translation data than the server.
You can manually inspect by running a small script and grepping the output (cv scr printsql.php | grep Neue
):
function _getSqlLive($locale) {
$schema = new \CRM_Core_CodeGen_Schema(\Civi\Test::codeGen());
$files = $schema->generateLocaleDataSql($locale);
foreach ($files as $file => $content) {
if (preg_match(';^civicrm_data\.;', $file)) {
return $content;
}
}
throw new \Exception("Failed to generate $locale");
}
echo _getSqlLive('de_DE');
Both outputs include some translated strings, but the newer doesn't have as many:
---Local machine, old data
+++Server machine, new data
("Individual,Contact",NULL,"4","0","1","new_individual","Neue Person"),
-("Organization,Contact",NULL,"5","0","1","new_organization","Neue Organisation"),
-("Household,Contact",NULL,"6","0","1","new_household","Neuer Haushalt"),
+("Organization,Contact",NULL,"5","0","1","new_organization","New Organization"),
+("Household,Contact",NULL,"6","0","1","new_household","New Household"),
If I inspect the data (msgunfmt civicrm.mo -o civicrm.po
), I find these in the old data-set:
msgid "New Individual"
msgstr "Neue Person"
msgid "New Organization"
msgstr "Neue Organisation"
msgctxt "menu"
msgid "New Individual"
msgstr "Neue Person"
msgctxt "menu"
msgid "New Organization"
msgstr "Neue Organisation"
And these in the new data-set:
msgid "New Individual"
msgstr "Neue Person"
msgctxt "menu"
msgid "New Individual"
msgstr "Neue Person"
msgctxt "menu"
msgid "New Organization"
msgstr "Neue Organisation"
So it's missing New Organization
in the default context. Additionally, the phrases Phone Call
and Meeting
appear in the old data-set but not the new data-set. I see similar omissions in fr_FR
.
I assume that the SQL translation is evaluating everything in the default context. (It doesn't seem to use the menu
translations). I don't know if that's good or bad. But regardless, it's probably bad that Phone Call
and Meeting
are missing.
In the CI logs for testTranslatedData()
, the failure starts on roughly Feb 4. (Some places seem to start Feb 5 -- l10n data is cached for a bit.) I'm guessing this is related the new strings released around Feb 4 (https://chat.civicrm.org/civicrm/pl/jyqia56a47dp5dnrouiabnmnuw).
(ping @bgm)