I am trying to create a translation file in simplified Chinese from an English source. This is all happening in a Flask project and I've been using Flask-Babel (so far successfully) to translate to Spanish and French. I added a Chinese translation file but I'm running into the following issue.
Consider the following strings in English:
msgid "One message"
msgid_plural "%(num)d messages"
When there is only one message, I don't want to display the number 1
, I want the spelled out version.
Apparenly, in Chinese, there is no grammatical difference between singular and plural, so our translators only included one translation for both versions:
msgstr[0] "%(num)d [something in Chinese]"
When I tried to compile this file, I got the following error message:
unknown named placeholder 'num'
So I tried to duplicate the line like this (一
is 1 in Chinese):
msgstr[0] "一 [something in Chinese]"
msgstr[1] "%(num)d [something in Chinese]"
But then I got this error:
msg has more translations than num_plurals of catalog
which makes sense: Chinese has a nplurals
of 1 so there shouldn't be more than one msgstr
.
I see two options at this stage:
- Cheat on my Chinese .po file and declare that
nplurals = 2
with the same rule as English:"Plural-Forms: nplurals=2; plural=(n > 1)"
. - Update all my source strings so that I always use
%(num)d
in the singular version if I need it in the plural version.
I'm not really satisfied with either option. Is there an alternative?