Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Keep the [zero] case as a separate unit.

This allows all languages to translate it specifically, not
just languages with a rule specifically for [zero].
  • Loading branch information...
commit 00926f2f1a2d122bad533433a576ef240dcc9761 1 parent 9f9f1ff
friedelwolff authored August 15, 2012
3  translate/convert/po2prop.py
@@ -73,6 +73,9 @@ def _explode_gaia_plurals(self):
73 73
             for category, text in zip(names, unit.target.strings):
74 74
                 # TODO: for now we assume all forms are present. We need to
75 75
                 # fill in the rest after mapping things to the proper CLDR names.
  76
+                if category == 'zero':
  77
+                    # [zero] cases are translated as separate units
  78
+                    continue
76 79
                 new_unit = self.inputstore.addsourceunit(u"fish") # not used
77 80
                 new_location = '%s[%s]' % (location, category)
78 81
                 new_unit.addlocation(new_location)
4  translate/convert/prop2po.py
@@ -159,7 +159,9 @@ def fold_gaia_plurals(self, postore):
159 159
                 location = unit.getlocations()[0]
160 160
                 if current_plural and location.startswith(current_plural):
161 161
                     plurals[current_plural].append(unit)
162  
-                    continue
  162
+                    if not '[zero]' in location:
  163
+                        # We want to keep [zero] cases separately translatable
  164
+                        continue
163 165
                 elif current_plural:
164 166
                     # End of a set of plural units
165 167
                     new_unit = _collapse(new_store, plurals[current_plural])
10  translate/convert/test_po2prop.py
@@ -190,10 +190,16 @@ def test_gaia_plurals(self):
190 190
 message-multiedit-header[many]={{ n }} selected
191 191
 message-multiedit-header[other]={{ n }} selected
192 192
 '''
193  
-        posource = r'''#: message-multiedit-header
  193
+        posource = r'''#: message-multiedit-header[zero]
  194
+msgctxt "message-multiedit-header[zero]"
  195
+msgid "Edit"
  196
+msgstr "Redigeer"
  197
+
  198
+#: message-multiedit-header
  199
+msgctxt "message-multiedit-header"
194 200
 msgid "Edit"
195 201
 msgid_plural "{{ n }} selected"
196  
-msgstr[0] "Redigeer"
  202
+msgstr[0] "xxxRedigeerxxx"
197 203
 msgstr[1] "{{ n }} gekies"
198 204
 msgstr[2] "{{ n }} gekies"
199 205
 msgstr[3] "{{ n }} gekies"
7  translate/convert/test_prop2po.py
@@ -239,10 +239,15 @@ def test_gaia_plurals(self):
239 239
         inputfile = wStringIO.StringIO(propsource)
240 240
         inputprop = properties.propfile(inputfile, personality="gaia")
241 241
         outputpo = convertor.convertstore(inputprop, personality="gaia")
242  
-        pounit = self.singleelement(outputpo)
  242
+        pounit = outputpo.units[-1]
243 243
         assert pounit.hasplural()
244 244
         assert pounit.getlocations() == [u'message-multiedit-header']
245 245
 
  246
+        print outputpo
  247
+        zero_unit = outputpo.units[-2]
  248
+        assert not zero_unit.hasplural()
  249
+        assert zero_unit.source == u"Edit"
  250
+
246 251
 class TestProp2POCommand(test_convert.TestConvertCommand, TestProp2PO):
247 252
     """Tests running actual prop2po commands on files"""
248 253
     convertmodule = prop2po

0 notes on commit 00926f2

Please sign in to comment.
Something went wrong with that request. Please try again.