Translation of the plural and zero in Russian returns the name of the variable


#1

Intro

I’m translating a theme and it seems to me I caught an issue.

I don’t understand why Hugo returns the name of a variable instead of reporting a problem if one exists.

Configs

Hugo

$> hugo version
Hugo Static Site Generator v0.50-DEV/extended linux/amd64 BuildDate: unknown

$> whereis hugo
hugo: /home/user/go/bin/hugo

$> go version
go version go1.11 linux/amd64

My config.toml

baseURL = "/"
languageCode = "en-us"
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = true
enableMissingTranslationPlaceholders = true
copyright = "Everything is mine"

[languages]
  [languages.en]
    title = "EN"
    weight = 1
  [languages.ru]
    title = "RU"
    weight = 2
  [languages.ru-RU]
    title = "ru_RU"
    weight = 2.5
  [languages.ua]
    title = "UA"
    weight = 3
  [languages.fr]
    title = "FR"
    weight = 4

The directory i18n also has all translated.

en.yaml

- id: variable_id
  translation:
    one: one
    other: other

ru.yaml

- id: variable_id
  translation:
    one: один
    other: много

ru_RU.yaml

- id: variable_id
  translation:
    one: один
    other: много

ua.yaml

- id: variable_id
  translation:
    one: один
    other: багато

fr.yaml

- id: variable_id
  translation:
    one: one
    other: other
Build

The build also is fine.

$> hugo serve --i18n-warnings --verbose
ERROR 2018/10/30 23:35:22 port 1313 already in use, attempting to use an available port
INFO 2018/10/30 23:35:22 Using config file: /raid/user/github.com/oshliaer/gists/47d150374ecece4a9e1547ea72eec7b3/site/config.toml
Building sites … INFO 2018/10/30 23:35:22 syncing static files to /
INFO 2018/10/30 23:35:22 Alias "/" translated to "/index.html"
INFO 2018/10/30 23:35:22 Alias "/" translated to "/index.html"
INFO 2018/10/30 23:35:22 Alias "/" translated to "/index.html"
INFO 2018/10/30 23:35:22 Alias "/" translated to "/index.html"
INFO 2018/10/30 23:35:22 Alias "/" translated to "/index.html"

                   | EN | RU | RU-RU | UA | FR
+------------------+----+----+-------+----+----+
  Pages            |  4 |  4 |     4 |  4 |  4
  Paginator pages  |  0 |  0 |     0 |  0 |  0
  Non-page files   |  0 |  0 |     0 |  0 |  0
  Static files     |  0 |  0 |     0 |  0 |  0
  Processed images |  0 |  0 |     0 |  0 |  0
  Aliases          |  1 |  1 |     1 |  1 |  1
  Sitemaps         |  2 |  1 |     1 |  1 |  1
  Cleaned          |  0 |  0 |     0 |  0 |  0

Total in 12 ms
Watching for changes in /raid/user/github.com/oshliaer/gists/47d150374ecece4a9e1547ea72eec7b3/site/{content,data,i18n,layouts,static}
Watching for config changes in /raid/user/github.com/oshliaer/gists/47d150374ecece4a9e1547ea72eec7b3/site/config.toml
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:36131/ (bind address 127.0.0.1)
Press Ctrl+C to stop

The problem

But the Russian translation is fail. Translation of the plural and zero in Russian returns the id of the variable variable_id.

The example https://hugo_plural_form_russian.surge.sh

Please look at the assets below.

Any suggestion?

Assets

en
fr
ua
ru

How to repeat

#2

#3

From the article

If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.

I have a full translation.

But variable id is returned instead a value from the default language or an empty string.

I added an example https://hugo_plural_form_russian.surge.sh


#5

@oshliaer I downloaded your repo (TIL you can upload a tarball to a gist, nice!) and tested.

I noticed that the language code for russian language is either ru or rus. I tried rus instead, and it seems to have worked.

Updated line 14 of config.toml to be [languages.rus], and then updated the i18n file to be rus.yaml.

Doing that, I can see the russian language terms under the RU section now. I’m afraid I am not sure why but maybe this gives you a hint…


#6

Also, reading the docs on i18n, it is seemingly referring to this:

https://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html

… for lang codes and, rus is not mentioned. I wonder, does it mean that it is choking on that second ru-ru code you had? Maybe try removing it and see what happens.


#7

Hi @RickCogley

Thanks for the great suggestion! It works!

What I tried also:

  • Remove all ru-variants except one. The issue is there.
  • Try ru-ru, ru_ru, ru-RU, ru_RU. Nothing.

Should I insist on a bug? Or is it not a problem of Hugo?

Thank you again.

Cheers!

Updated

  • The repo of the full example
  • The host of the example