Skip to content

Commit

Permalink
Keep the [zero] case as a separate unit.
Browse files Browse the repository at this point in the history
This allows all languages to translate it specifically, not
just languages with a rule specifically for [zero].
  • Loading branch information
friedelwolff committed Aug 17, 2012
1 parent 9f9f1ff commit 00926f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions translate/convert/po2prop.py
Expand Up @@ -73,6 +73,9 @@ def _explode_gaia_plurals(self):
for category, text in zip(names, unit.target.strings): for category, text in zip(names, unit.target.strings):
# TODO: for now we assume all forms are present. We need to # TODO: for now we assume all forms are present. We need to
# fill in the rest after mapping things to the proper CLDR names. # fill in the rest after mapping things to the proper CLDR names.
if category == 'zero':
# [zero] cases are translated as separate units
continue
new_unit = self.inputstore.addsourceunit(u"fish") # not used new_unit = self.inputstore.addsourceunit(u"fish") # not used
new_location = '%s[%s]' % (location, category) new_location = '%s[%s]' % (location, category)
new_unit.addlocation(new_location) new_unit.addlocation(new_location)
Expand Down
4 changes: 3 additions & 1 deletion translate/convert/prop2po.py
Expand Up @@ -159,7 +159,9 @@ def fold_gaia_plurals(self, postore):
location = unit.getlocations()[0] location = unit.getlocations()[0]
if current_plural and location.startswith(current_plural): if current_plural and location.startswith(current_plural):
plurals[current_plural].append(unit) plurals[current_plural].append(unit)
continue if not '[zero]' in location:
# We want to keep [zero] cases separately translatable
continue
elif current_plural: elif current_plural:
# End of a set of plural units # End of a set of plural units
new_unit = _collapse(new_store, plurals[current_plural]) new_unit = _collapse(new_store, plurals[current_plural])
Expand Down
10 changes: 8 additions & 2 deletions translate/convert/test_po2prop.py
Expand Up @@ -190,10 +190,16 @@ def test_gaia_plurals(self):
message-multiedit-header[many]={{ n }} selected message-multiedit-header[many]={{ n }} selected
message-multiedit-header[other]={{ n }} selected message-multiedit-header[other]={{ n }} selected
''' '''
posource = r'''#: message-multiedit-header posource = r'''#: message-multiedit-header[zero]
msgctxt "message-multiedit-header[zero]"
msgid "Edit"
msgstr "Redigeer"
#: message-multiedit-header
msgctxt "message-multiedit-header"
msgid "Edit" msgid "Edit"
msgid_plural "{{ n }} selected" msgid_plural "{{ n }} selected"
msgstr[0] "Redigeer" msgstr[0] "xxxRedigeerxxx"
msgstr[1] "{{ n }} gekies" msgstr[1] "{{ n }} gekies"
msgstr[2] "{{ n }} gekies" msgstr[2] "{{ n }} gekies"
msgstr[3] "{{ n }} gekies" msgstr[3] "{{ n }} gekies"
Expand Down
7 changes: 6 additions & 1 deletion translate/convert/test_prop2po.py
Expand Up @@ -239,10 +239,15 @@ def test_gaia_plurals(self):
inputfile = wStringIO.StringIO(propsource) inputfile = wStringIO.StringIO(propsource)
inputprop = properties.propfile(inputfile, personality="gaia") inputprop = properties.propfile(inputfile, personality="gaia")
outputpo = convertor.convertstore(inputprop, personality="gaia") outputpo = convertor.convertstore(inputprop, personality="gaia")
pounit = self.singleelement(outputpo) pounit = outputpo.units[-1]
assert pounit.hasplural() assert pounit.hasplural()
assert pounit.getlocations() == [u'message-multiedit-header'] assert pounit.getlocations() == [u'message-multiedit-header']


print outputpo
zero_unit = outputpo.units[-2]
assert not zero_unit.hasplural()
assert zero_unit.source == u"Edit"

class TestProp2POCommand(test_convert.TestConvertCommand, TestProp2PO): class TestProp2POCommand(test_convert.TestConvertCommand, TestProp2PO):
"""Tests running actual prop2po commands on files""" """Tests running actual prop2po commands on files"""
convertmodule = prop2po convertmodule = prop2po
Expand Down

0 comments on commit 00926f2

Please sign in to comment.