From 2a9d364bb78c0784f990753c96db16e1d036a34d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 17 May 2018 07:57:55 +0200 Subject: [PATCH 1/3] i18n ru intval bug Should fix: Got error 'PHP message: PHP Warning: A non-numeric value encountered in /home/alex/public_html/f.a80.fr/view/lang/ru/strings.php on line 5\n PHP 7.2.5 / Ubuntu 18.04 LTS --- view/lang/ru/strings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/view/lang/ru/strings.php b/view/lang/ru/strings.php index 27aa61a1a..c65b8aba2 100644 --- a/view/lang/ru/strings.php +++ b/view/lang/ru/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_ru")) { function string_plural_select_ru($n){ + $n = intval($n); return ($n%10==1 && $n%100!=11 ? 0 : $n%10>=2 && $n%10<=4 && ($n%100<12 || $n%100>14) ? 1 : $n%10==0 || ($n%10>=5 && $n%10<=9) || ($n%100>=11 && $n%100<=14)? 2 : 3);; }} ; From f980516545f4146c0e5017f940c7353670ece2d4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 17 May 2018 08:12:55 +0200 Subject: [PATCH 2/3] Fix PoToPhp https://github.com/friendica/friendica/pull/5072#issuecomment-389754406 --- src/Core/Console/PoToPhp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core/Console/PoToPhp.php b/src/Core/Console/PoToPhp.php index 62ff24bd5..e97e1ff3d 100644 --- a/src/Core/Console/PoToPhp.php +++ b/src/Core/Console/PoToPhp.php @@ -94,6 +94,7 @@ HELP; $fnname = 'string_plural_select_' . $lang; $out .= 'if(! function_exists("' . $fnname . '")) {' . "\n"; $out .= 'function ' . $fnname . '($n){' . "\n"; + $out .= ' $n = intval($n);' . "\n"; $out .= ' return ' . $cond . ';' . "\n"; $out .= '}}' . "\n"; } From 102377f19fecba3c1ea5bfeedf36f0df67e1063d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 17 May 2018 09:31:29 +0200 Subject: [PATCH 3/3] Rebuild PO to strings ```sh for i in view/lang/*/messages.po; do bin/console po2php $i; done ``` --- view/lang/bg/strings.php | 1 + view/lang/ca/strings.php | 1 + view/lang/cs/strings.php | 1 + view/lang/de/strings.php | 1 + view/lang/en-gb/strings.php | 1 + view/lang/en-us/strings.php | 1 + view/lang/eo/strings.php | 1 + view/lang/es/strings.php | 1 + view/lang/fi-fi/strings.php | 1 + view/lang/fr/strings.php | 1 + view/lang/is/strings.php | 1 + view/lang/it/strings.php | 1 + view/lang/nb-no/strings.php | 1 + view/lang/nl/strings.php | 1 + view/lang/pl/strings.php | 1 + view/lang/pt-br/strings.php | 1 + view/lang/ro/strings.php | 1 + view/lang/sv/strings.php | 1 + view/lang/zh-cn/strings.php | 1 + 19 files changed, 19 insertions(+) diff --git a/view/lang/bg/strings.php b/view/lang/bg/strings.php index 8d3bf4d5c..b70ac3b1a 100644 --- a/view/lang/bg/strings.php +++ b/view/lang/bg/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_bg")) { function string_plural_select_bg($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/ca/strings.php b/view/lang/ca/strings.php index 5e891565c..dbf3919c6 100644 --- a/view/lang/ca/strings.php +++ b/view/lang/ca/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_ca")) { function string_plural_select_ca($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/cs/strings.php b/view/lang/cs/strings.php index 8237019ee..efc9ecd34 100644 --- a/view/lang/cs/strings.php +++ b/view/lang/cs/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_cs")) { function string_plural_select_cs($n){ + $n = intval($n); return ($n==1) ? 0 : ($n>=2 && $n<=4) ? 1 : 2;; }} ; diff --git a/view/lang/de/strings.php b/view/lang/de/strings.php index 32e3f8f15..9cb9559fb 100644 --- a/view/lang/de/strings.php +++ b/view/lang/de/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_de")) { function string_plural_select_de($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/en-gb/strings.php b/view/lang/en-gb/strings.php index a2c1a944f..50333b15b 100644 --- a/view/lang/en-gb/strings.php +++ b/view/lang/en-gb/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_en_gb")) { function string_plural_select_en_gb($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/en-us/strings.php b/view/lang/en-us/strings.php index f73717926..377ad314a 100644 --- a/view/lang/en-us/strings.php +++ b/view/lang/en-us/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_en_us")) { function string_plural_select_en_us($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/eo/strings.php b/view/lang/eo/strings.php index c7dbcb4ff..3704fd32f 100644 --- a/view/lang/eo/strings.php +++ b/view/lang/eo/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_eo")) { function string_plural_select_eo($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/es/strings.php b/view/lang/es/strings.php index f12d61b7a..530ea979c 100644 --- a/view/lang/es/strings.php +++ b/view/lang/es/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_es")) { function string_plural_select_es($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/fi-fi/strings.php b/view/lang/fi-fi/strings.php index 16c3e9539..7e96af9b4 100644 --- a/view/lang/fi-fi/strings.php +++ b/view/lang/fi-fi/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_fi_fi")) { function string_plural_select_fi_fi($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/fr/strings.php b/view/lang/fr/strings.php index 34c805e99..67d403888 100644 --- a/view/lang/fr/strings.php +++ b/view/lang/fr/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_fr")) { function string_plural_select_fr($n){ + $n = intval($n); return ($n > 1);; }} ; diff --git a/view/lang/is/strings.php b/view/lang/is/strings.php index fda0c85bf..d67b45816 100644 --- a/view/lang/is/strings.php +++ b/view/lang/is/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_is")) { function string_plural_select_is($n){ + $n = intval($n); return ($n % 10 != 1 || $n % 100 == 11);; }} ; diff --git a/view/lang/it/strings.php b/view/lang/it/strings.php index 91c74d77a..e4548eb24 100644 --- a/view/lang/it/strings.php +++ b/view/lang/it/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_it")) { function string_plural_select_it($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/nb-no/strings.php b/view/lang/nb-no/strings.php index 18351bada..6f1c49a22 100644 --- a/view/lang/nb-no/strings.php +++ b/view/lang/nb-no/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_nb_no")) { function string_plural_select_nb_no($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/nl/strings.php b/view/lang/nl/strings.php index 5b74f580a..878ede7cb 100644 --- a/view/lang/nl/strings.php +++ b/view/lang/nl/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_nl")) { function string_plural_select_nl($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/pl/strings.php b/view/lang/pl/strings.php index 27b381f93..6d4d6ed09 100644 --- a/view/lang/pl/strings.php +++ b/view/lang/pl/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_pl")) { function string_plural_select_pl($n){ + $n = intval($n); return ($n==1 ? 0 : ($n%10>=2 && $n%10<=4) && ($n%100<12 || $n%100>14) ? 1 : $n!=1 && ($n%10>=0 && $n%10<=1) || ($n%10>=5 && $n%10<=9) || ($n%100>=12 && $n%100<=14) ? 2 : 3);; }} ; diff --git a/view/lang/pt-br/strings.php b/view/lang/pt-br/strings.php index 1c3d47bc0..5df9b3a2e 100644 --- a/view/lang/pt-br/strings.php +++ b/view/lang/pt-br/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_pt_br")) { function string_plural_select_pt_br($n){ + $n = intval($n); return ($n > 1);; }} ; diff --git a/view/lang/ro/strings.php b/view/lang/ro/strings.php index fcbbfa5d1..50e963b08 100644 --- a/view/lang/ro/strings.php +++ b/view/lang/ro/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_ro")) { function string_plural_select_ro($n){ + $n = intval($n); return ($n==1?0:((($n%100>19)||(($n%100==0)&&($n!=0)))?2:1));; }} ; diff --git a/view/lang/sv/strings.php b/view/lang/sv/strings.php index e25c03293..f7276ce62 100644 --- a/view/lang/sv/strings.php +++ b/view/lang/sv/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_sv")) { function string_plural_select_sv($n){ + $n = intval($n); return ($n != 1);; }} ; diff --git a/view/lang/zh-cn/strings.php b/view/lang/zh-cn/strings.php index 4747c791b..3868fda99 100644 --- a/view/lang/zh-cn/strings.php +++ b/view/lang/zh-cn/strings.php @@ -2,6 +2,7 @@ if(! function_exists("string_plural_select_zh_cn")) { function string_plural_select_zh_cn($n){ + $n = intval($n); return 0;; }} ;