Skip to content
Snippets Groups Projects
Commit 6a562f24 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#566390 by Gábor Hojtsy, seutje, Jose Reyero: Apply locale import protection...

#566390 by Gábor Hojtsy, seutje, Jose Reyero: Apply locale import protection user setting to plural forms the same way we apply to other parts of the .po file
parent 3d0a97ff
No related branches found
No related tags found
No related merge requests found
......@@ -1287,15 +1287,21 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
case 'db-store':
// We got header information.
if ($value['msgid'] == '') {
$header = _locale_import_parse_header($value['msgstr']);
// Get the plural formula and update in database.
if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) {
list($nplurals, $plural) = $p;
db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang);
}
else {
db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", 0, '', $lang);
$languages = language_list();
if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) {
// Since we only need to parse the header if we ought to update the
// plural formula, only run this if we don't need to keep existing
// data untouched or if we don't have an existing plural formula.
$header = _locale_import_parse_header($value['msgstr']);
// Get the plural formula and update in database.
if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) {
list($nplurals, $plural) = $p;
db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang);
}
else {
db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", 0, '', $lang);
}
}
$headerdone = TRUE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment