Open kuzminT opened 1 year ago
I was going through the specific function. IF your key.Name
is the same, as it should, for single and plural, then it should work.
// Set the (N)th plural form for the given string
func (do *Domain) SetN(id, plural string, n int, str string) {
// Get plural form _before_ lock down
pluralForm := do.pluralForm(n)
do.trMutex.Lock()
do.pluralMutex.Lock()
defer do.trMutex.Unlock()
defer do.pluralMutex.Unlock()
if trans, ok := do.translations[id]; ok {
trans.SetN(pluralForm, str)
} else {
trans = NewTranslation()
trans.ID = id
trans.PluralID = plural
trans.SetN(pluralForm, str)
do.translations[str] = trans
}
}
See line if trans, ok := do.translations[id]; ok {
@kuzminT , I have found the issue .. in the snippet above you see do.translations[str] = trans
, this should be do.translations[id] = trans
I have forked this repo since it is not active at the moment https://github.com/donseba/gotext
Please describe your issue
We're trying to use this package to parse translations from PO files or export them into PO. When we use parsing, it's clear and works well. Now I'm trying to create a new PO and have managed to do it with a string format, but there are some troubles with plurals. I couldn't find any example of how to work with them. Instead of getting one key and several translation variants for it, I have several separate keys and translations. Also, most of the properties for working with objects are private and I can't use them. So I'm doing something like this:
And as result in the file I see this strings:
But it is not what I wanted, certainly. I could just concatenate some strings by myself, but we wanted to use this library and not work with bare hands.
Is this a bug, an improvement, a proposal or something else? Describe it.
Perhaps it's not a bug, just a lack of documentation. It would be great if the package were supplemented with similar examples.