-
Notifications
You must be signed in to change notification settings - Fork 277
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
no plural rule registered for zh-Hant #107
Comments
This should work. There is a plural rule for On bundle.go:96 either If you could debug that would be helpful. |
Thanks for your reply. I hacked the local code to work for my needs. But I'm don't know if this is a correct fix (the Parent()@golang.org/x/text/language/language.go:338 does not think of zh as parent of zh-Hant). Here's my [email protected]:10, which uses the base language to match: func (r Rules) Rule(tag language.Tag) *Rule {
for {
if rule := r[tag]; rule != nil {
return rule
}
tag = tag.Parent()
if tag.IsRoot() {
break
}
}
base, _ := tag.Base()
baseLang := language.MustParse(base.String())
if rule := r[baseLang]; rule != nil {
return rule
}
return nil
} |
Thanks for figuring this out. I am not sure if the behavior you are observing from golang.org/x/text/language is intentional or not so I filed golang/go#25603 Can you clarify what your use-case is? Your source translations are in zh-Hans and you are translating to zh-Hant? |
I pushed a fix to master. I found some bugs in your proposed workaround, so take a look. |
Thanks for the fix and figuring the bug. localesMap = map[string]language.Tag{
"en": language.English,
"zh": language.SimplifiedChinese,
"zh-hans-cn": language.SimplifiedChinese,
"zh-hans": language.SimplifiedChinese,
"zh-cn": language.SimplifiedChinese,
"zh-hant": language.TraditionalChinese,
"zh-tw": language.TraditionalChinese,
"ja": language.Japanese,
"fr": language.French,
"ru": language.Russian,
"es": language.Spanish,
"ko": language.Korean,
"ar": language.Arabic,
} In the init proc I load the languages messages. But when langTag is language.TraditionalChinese, the AddMessage returns an error. err = i18nBundle.AddMessages(langTag, localeMsgs...)
if err != nil {
log.WithFields(log.Fields{"file": fi.Name(), "error": err}).Warn("add messages error")
} When language is language.TraditionalChinese, the translation process returns SimplifiedChinese. localizer := i18n.NewLocalizer(i18nBundle, language) |
hi,
I want i18n to translate between zh-Hans and zh-Hant. But the result was not expcted, and was always translated to zh-Hans. I follow the code and found code @bundle.go:98 returns an error.
return fmt.Errorf("no plural rule registered for %s", tag)
It seems no plural rule registered for zh-Hant. so the messages can't be registered.
Is this a bug?
The text was updated successfully, but these errors were encountered: