jQuery-Word-and-Character-Counter-Plugin
jQuery-Word-and-Character-Counter-Plugin copied to clipboard
Improve translation support
Hi! As I see in the plugin source have a small bug with translation. At least with plural. If I trying to translate like this
...
translation: 'знак слово осталось макс' // In russian
...
I see 0 знак(s) осталось
. The (s)
is always available in string because hardcoded at https://github.com/qwertypants/jQuery-Word-and-Character-Counter-Plugin/blob/master/jquery.word-and-character-counter.js#L120
Any ideas how to fix it? And how about support plurals and singulars?
Maybe it's best to convert translate
into array with translations for every part of string?
It's even more difficult, because some languages (like Russian) have more than one plural form. If I remember my Russian correctly... if it was one word, "слово", between 2 and 4 words, "слова", and five or more words, "слов".
Sometimes a plural form is a completely different word, like "year" is 1 "год", 2-4 "года", or 5 "лет", so there's no pattern.
To add to the complexity, other languages (like Inuktitut) have a dual form for two and a different plural for more than two instead of breaking at five.
Just want to add a note that I may have found something that accounts for plural rules in different languages. Found it in the go-i18n project.
So an English translation file would contain this:
[
{
"id": "word",
"translation": {
"one": "{{.Count}} word",
"other": "{{.Count}} words"
}
},
{
"id": "character",
"translation": {
"one": "{{.Count}} character",
"other": "{{.Count}} characters"
}
},
]
And a Russian version would be something like this:
[
{
"id": "word",
"translation": {
"one": "{{.Count}} слово",
"few": "{{.Count}} слова",
"other": "{{.Count}} слов"
}
},
{
"id": "character",
"translation": {
"one": "{{.Count}} знак",
"few": "{{.Count}} знака",
"other": "{{.Count}} знаков"
}
},
]
Good news. Waiting for new release ;)
I don't think that I'll have time to do a pull request anytime soon. But this would also fix issue #6 too.