Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilingual: 'message "xxxx" has no plural form for "one" #7839

Closed
cyChop opened this issue Oct 15, 2020 · 8 comments
Closed

Multilingual: 'message "xxxx" has no plural form for "one" #7839

cyChop opened this issue Oct 15, 2020 · 8 comments

Comments

@cyChop
Copy link

cyChop commented Oct 15, 2020

With the latest updates, my site generation generates a lot of warnings like the following:

i18n|MISSING_TRANSLATION|fr|xxxxxx
WARN 2020/10/15 18:34:15 Failed to get translated string for language "fr" and ID "xxxxxx": message "readingTimeShort" has no plural form "one"

I use the "--i18n-warnings" option. Some of the concerned messages use a dynamic count, others don't.

The messages that generate these messages are called with a .Count argument ({{- i18n "xxxxxx" $count -}}), but don't need specific singular/plural forms.

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.76.5-60F0725B/extended linux/amd64 BuildDate: 2020-10-14T15:25:14Z

Does this issue reproduce with the latest release?

Yes.

@bep bep added this to the v0.76.6 milestone Oct 16, 2020
@bep
Copy link
Member

bep commented Oct 16, 2020

I will have a look at this soonish, but today I'm busy busy with other things. This i18n upgrade from v1 to v2 was certainly more painful than I expected, but hopefully it's worth it.

@cyChop
Copy link
Author

cyChop commented Oct 16, 2020

That is certainly not a priority. These are only warnings, but the site is correctly generated nonetheless.

Thanks for having a look at it anyway! :)

@bep bep modified the milestones: v0.76.6, v0.77, v0.78 Oct 30, 2020
@jmooring
Copy link
Member

About the warnings...
gohugoio/hugoDocs#1410 (comment)

@jmooring
Copy link
Member

@cyChop I suspect that the warnings are correct, and would like to close this issue. Please review my comments here, and let me know your thoughts. Thanks.

@cyChop
Copy link
Author

cyChop commented Apr 22, 2021

Hi @jmooring ! Obviously, the warning is correct, but it was a surprising behaviour change.

Although the current implementation of https://github.com/nicksnyder/go-i18n uses other as a fallback category when the correct category is not defined, it was never intended to be used that way. The other category is explicitly defined by the CLDR plural rules, and is an implicit fallback only when all other categories for a given language are defined.

This seems to be exactly what happens. And from the formalism of go-18n, it makes sense. I just went to Hugo's multilingual documentation and see that I'm still using the old formalism, where precising the one or other was not mandatory.

For instance, I still have:

- id: wordCount
  translation: This article has {{ .WordCount }} words.

instead of

wordCount:
  other: This article has {{ .WordCount }} words.

With this new approach, this issue is obsolete and may be closed. I'll let the project contributors do it.

I just have one question for you, @jmooring , since you seem to know your way around go-i18n much better than me: is there a way to tell go-i18n explicitly to fall back to other? I hate duplicating, but the only way I can think of correcting this warning in my project would be the following:

readingTime:
  one: {{ .Count }} min. reading
  other: {{ .Count }} min. reading

Thanks for having had a look at it!

@jmooring
Copy link
Member

@cyChop

is there a way to tell go-i18n explicitly to fall back to other?

No.

If it falls back to other due to a missing translation, a warning message will be generated.

If it falls back to other due to a missing translation and other is not defined, the output will be an empty string, and a warning message will be generated.

@salim-b
Copy link
Contributor

salim-b commented May 1, 2021

So, an issue I've noticed after upgrading to Hugo 0.83: When you want to use "simple" i18n without pluralization, it now depends on the language whether you have to define other or one!

When you call i18n without a count, say i18n "read_more", i18n internally assumes a .Count value of 0. That means, while you have to define other in i18n/en.toml...

[read_more]
other = "Read more"

...you'll have to define one in i18n/fr.toml...

[read_more]
one = "Lire la suite"

... in order to avoid the warning message:

WARN (...) Failed to get translated string for language "fr" and ID "read_more": message "read_more" has no plural form "one"

(The warning message is also suboptimal in talking of a plural form "one"... might be better to use a sentence like has no cardinal form "[one|few|other|...]")

This is because the Language Plural Rules for fr are different than those for en (and most other european languages): For en, the one form is only used when i = 1 and v = 0 but for fr, the one form is always used when i = 0,1.


Now while technically this seems all fine, it would be awesome if Hugo could make life easier for theme authors: If a translation is specified without an explicit cardinal form (what @cyChop called the "old formalism"), Hugo should not blindly assign it to other but rather respect Language Plural Rules and thus assign it to other for en but to one for fr etc.

What do you think, @jmooring?

salim-b added a commit to salim-b/airspace-hugo that referenced this issue May 1, 2021
Because of some recent [language/i18n fixes](language/i18n fixes) Hugo 0.83+ started to complain about missing `fr` translations for cardinal form `"one"`. This is due to the fact that French uses different language plural rules than English, German, Italian and others. See gohugoio/hugo#7839 (comment) for an explanation of the underlying issue.
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants