Plural doesn't work for Brazillian Portuguese and Polish

I’m having the same type of problem as in

but for Polish and Brazillian Portuguese.

i18n/br.toml-  one = "Resposta tipicamente em 1 hora."
i18n/br.toml-  other = "Resposta tipicamente em {{ .Count }} horas."
i18n/de-AT.toml-  one = "Antworten innerhalb von 1 Stunde."
i18n/de-AT.toml-  other = "Antworten innerhalb von {{ .Count }} Stunden."
i18n/en.toml-  one = "Replies typically within 1 hour."
i18n/en.toml-  other = "Replies typically within {{ .Count }} hours."
i18n/es.toml-  one = "Responde normalmente en 1 hora."
i18n/es.toml-  other = "Responde normalmente en {{ .Count }} horas."
i18n/fr.toml-  one = "Réponse généralement en 1 heure."
i18n/fr.toml-  other = "Réponse généralement en {{ .Count }} heures."
i18n/pl.toml-  one = "Odpowiada zazwyczaj w ciagu 1 godzina."
i18n/pl.toml-  other = "Odpowiada zazwyczaj w ciagu {{ .Count }} godziny."
i18n/zh-CN.toml-  other = "一般回应需时 {{ .Count }} 小时"
i18n/zh-TW.toml-  other = "一般回应需时 {{ .Count }} 小时"
layouts/contact/list.html:                <h4>{{ i18n "repliestext" .Params.contactanswertime }}</h4>
layouts/contact/list.html-                <fieldset>
layouts/contact/list.html-                  <input placeholder="{{ with .Params.contactname }}{{ . }}{{ else }}Name{{ end }}" type="text" name="name" tabindex="1" required autofocus>

This works well for :uk: :fr: :de:.

Screenshots for sucessful results

However, for :brazil: Brazillian Portuguese and :poland: Polish, instead of showing the string above, the i18n key “repliestext” are displayed.

Project repo: my clone of the theme Hugo Future Imperfect Slim on the de-at branch.


Related issue:

From Unicode’s plural rules found in the linked Hugo issue, we see that there’re two missing lines in i18n/pl.toml breaking the plural behavior.

diff --git a/i18n/pl.toml b/i18n/pl.toml
index 91f21d0..ba18ca4 100644
--- a/i18n/pl.toml
+++ b/i18n/pl.toml
@@ -2,6 +2,8 @@
   other = "2-1-2006"
   one = "1 minuta czytania"
+  few = "{{ .Count }} minuty czytania"
+  many = "{{ .Count }} minuty czytania"
   other = "{{ .Count }} minuty czytania"
   other = "Ostatnie posty"
@@ -27,6 +29,8 @@
   other = "dowiedz się więcej"
   one = "Odpowiada zazwyczaj w ciagu 1 godzina."
+  few = "Odpowiada zazwyczaj w ciagu {{ .Count }} godziny."
+  many = "Odpowiada zazwyczaj w ciagu {{ .Count }} godziny."
   other = "Odpowiada zazwyczaj w ciagu {{ .Count }} godziny."
   other = "Prześlij"

Adding the missing cases few and many back gives the desired result.

Not tested, but I have an hypothesis you can test.

Try using pt-br or pt-BR instead of just br. Because in the usual language codes, there isn’t a br code.

|pt       | Portuguese                  |
|pt-BR    | Portuguese (Brazil)         |
|pt-PT    | Portuguese (Portugal)       |

But according to that page, PL does:

|pl      | Polish                      |
|pl-pl   | Polish (Poland)             |
1 Like

Thanks for feedback. I might try that for my theme Huginn later, but for Hugo Future Imperfect Slim, I’m thinking about backward compatibility issues.

Thanks to

doing the same thing on the :brazil: Brazillian Portuguese i18n/br.toml solve the problem.


I didn’t manage to get the suggestions for my previous question about i18n to work with i18n.

So far, I have to set the value languageCode to be equal to its parent’s key name to get things work, like

    languageCode        = "de-AT"
    LanguageName        = "Deutsch (Österreich)"

Since the i18n/br.toml has existed long before I started contributing to Hugo Future Imperfect Slim, renaming this might trigger backwards compatibility issues.

This solution indicates that it is an unknown language code, breaking the standard. It that may cause some problems down the line if you want to use language code for SEO meta tags or to output sitemaps.