From 739a3009ff008b70e2db7f4d48fc622c9f6c627f Mon Sep 17 00:00:00 2001 From: Mihai Vasiliu Date: Mon, 16 Dec 2019 21:21:07 +0200 Subject: [PATCH] [i18n] Fix Romanian plural forms (#5692) Hardcode the plural forms logic for Romanian. This fixes #5661 and enables Romanian (Moldova) language in the menu. --- frontend/gettext.lua | 5 +++++ frontend/ui/language.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/gettext.lua b/frontend/gettext.lua index fcb38047c..e01a6abd7 100644 --- a/frontend/gettext.lua +++ b/frontend/gettext.lua @@ -201,6 +201,11 @@ function GetText_mt.__index.changeLang(new_lang) local nplurals = plural_forms:match("nplurals=([0-9]+);") or 2 local plurals = plural_forms:match("plural=%((.*)%);") + -- Hardcoded workaround for Romanian which has 3 plural forms. + if plurals == "n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1)" then + plurals = "n==1 ? 0 : (n%100>19) || ((n%100==0) && (n!=0)) ? 2 : 1" + end + if not plurals then -- Some languages (e.g., Arabic) may not use parentheses. -- However, the following more inclusive match is more likely diff --git a/frontend/ui/language.lua b/frontend/ui/language.lua index 919429915..e67a96b24 100644 --- a/frontend/ui/language.lua +++ b/frontend/ui/language.lua @@ -130,7 +130,7 @@ function Language:getLangMenuTable() self:genLanguageSubItem("pt_PT"), self:genLanguageSubItem("pt_BR"), --self:genLanguageSubItem("ro"), - --self:genLanguageSubItem("ro_MD"), + self:genLanguageSubItem("ro_MD"), self:genLanguageSubItem("sk"), self:genLanguageSubItem("sv"), self:genLanguageSubItem("vi"),