From 8487fa6248d1d5dac81640de9c55c1eab9f324b3 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 15 May 2020 17:31:21 +0200 Subject: Reformat i18n correctly (#2976) * Ignore i18n gen.dir key * Add a makefile target to update an i18n key * Mark some i18n keys to ignore * Reformat i18n files correctly * Make i18n keys sort case-sensitive Calling `make i18n-format` was always inverting 4 lines: - gen.date.dec with gen.date.Dec - and gen.date.nov with gen.date.Nov I don't know why these particular lines and not the others, but it appeared the sort function was case insensitive due to the `SORT_FLAG_CASE` flag passed to the `ksort` function. Removing this flag makes the calls to the formatter idempotent and more reliable. Unfortunately it moves a lot of lines since the `_` character is considered differently. * Check i18n files are correctly formatted on Travis --- cli/i18n/I18nFile.php | 2 +- cli/i18n/ignore/cz.php | 5 +++++ cli/i18n/ignore/de.php | 5 +++++ cli/i18n/ignore/es.php | 21 ++++++++++++++++++ cli/i18n/ignore/fr.php | 10 +++++++++ cli/i18n/ignore/it.php | 5 +++++ cli/i18n/ignore/kr.php | 1 + cli/i18n/ignore/nl.php | 1 + cli/i18n/ignore/oc.php | 12 +++++++++++ cli/i18n/ignore/pt-br.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++ cli/i18n/ignore/ru.php | 5 +++++ cli/i18n/ignore/sk.php | 1 + cli/i18n/ignore/tr.php | 5 +++++ cli/i18n/ignore/zh-cn.php | 1 + 14 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 cli/i18n/ignore/cz.php create mode 100644 cli/i18n/ignore/de.php create mode 100644 cli/i18n/ignore/es.php create mode 100644 cli/i18n/ignore/it.php create mode 100644 cli/i18n/ignore/pt-br.php create mode 100644 cli/i18n/ignore/ru.php create mode 100644 cli/i18n/ignore/tr.php (limited to 'cli') diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php index c97520862..222d07692 100644 --- a/cli/i18n/I18nFile.php +++ b/cli/i18n/I18nFile.php @@ -79,7 +79,7 @@ class I18nFile implements I18nFileInterface{ private function unflatten($translation) { $a = array(); - ksort($translation, SORT_NATURAL | SORT_FLAG_CASE); + ksort($translation, SORT_NATURAL); foreach ($translation as $compoundKey => $value) { $keys = explode('.', $compoundKey); array_shift($keys); diff --git a/cli/i18n/ignore/cz.php b/cli/i18n/ignore/cz.php new file mode 100644 index 000000000..1c987d8b3 --- /dev/null +++ b/cli/i18n/ignore/cz.php @@ -0,0 +1,5 @@ +