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

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

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

@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…

1 Like

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.

1 Like

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

Changed it to rus and it fixed the problem!
Unlike OP, I had used just one ru translation code.

Came here to post about this problem and found a solution right away.
Thanks a lot!

1 Like

Updated Hugo to the latest 0.54 version, then chenged rus back to ru and it works just fine now. Now my site is fully compliant with international language code standards :smile:

1 Like

0.55.5 didn’t work with ‘ru’, worked with ‘rus’. Thanks!

1 Like

The same for me. There is no working solution right now?

0.57.1 works with ru fine.

The actual repo is Hugo plural form Russian · GitHub