You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
po := gotext.NewPo()
domain := po.GetDomain()
for i := range translations {
domain.SetN(key.Name, "some value", i, translations[i].Value)
}
And as result in the file I see this strings:
msgid "Just one user online"
msgid_plural "Just one user online"
msgstr[0] "Il y a %d utilisateurs en ligne"
msgid "Just one user online"
msgid_plural "Just one user online"
msgstr[1] "Un seul utilisateur en ligne"
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.
The text was updated successfully, but these errors were encountered:
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 stringfunc (do*Domain) SetN(id, pluralstring, nint, strstring) {
// Get plural form _before_ lock downpluralForm:=do.pluralForm(n)
do.trMutex.Lock()
do.pluralMutex.Lock()
deferdo.trMutex.Unlock()
deferdo.pluralMutex.Unlock()
iftrans, ok:=do.translations[id]; ok {
trans.SetN(pluralForm, str)
} else {
trans=NewTranslation()
trans.ID=idtrans.PluralID=pluraltrans.SetN(pluralForm, str)
do.translations[str] =trans
}
}
See line if trans, ok := do.translations[id]; ok {
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.
The text was updated successfully, but these errors were encountered: