Mercurial > p > roundup > code
comparison roundup/msgfmt.py @ 2801:ee9c3b850f9e
fix plural forms:
if the first translation string is empty, remaining translations were
applied to wrong cases. GNU msgfmt in such case deletes the
translation altogether; so do we now.
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Wed, 20 Oct 2004 08:46:45 +0000 |
| parents | 40643f8b41a0 |
| children | a6bf25d38518 |
comparison
equal
deleted
inserted
replaced
| 2800:3adcdd5b9247 | 2801:ee9c3b850f9e |
|---|---|
| 47 | 47 |
| 48 | 48 |
| 49 def add(id, str, fuzzy): | 49 def add(id, str, fuzzy): |
| 50 "Add a non-fuzzy translation to the dictionary." | 50 "Add a non-fuzzy translation to the dictionary." |
| 51 global MESSAGES | 51 global MESSAGES |
| 52 if not fuzzy and str: | 52 if not fuzzy and str and not str.startswith('\0'): |
| 53 MESSAGES[id] = str | 53 MESSAGES[id] = str |
| 54 | 54 |
| 55 | 55 |
| 56 | 56 |
| 57 def generate(): | 57 def generate(): |
| 148 elif l.startswith('msgstr'): | 148 elif l.startswith('msgstr'): |
| 149 section = STR | 149 section = STR |
| 150 l = l[6:] | 150 l = l[6:] |
| 151 # Check for plural forms | 151 # Check for plural forms |
| 152 if l.startswith('['): | 152 if l.startswith('['): |
| 153 # Separate plural forms with \0 | |
| 154 if not l.startswith('[0]'): | |
| 155 msgstr += '\0' | |
| 153 # Ignore the index - must come in sequence | 156 # Ignore the index - must come in sequence |
| 154 l = l[l.index(']') + 1:] | 157 l = l[l.index(']') + 1:] |
| 155 # Separate plural forms with \0 | |
| 156 if len(msgstr) > 0: | |
| 157 msgstr += '\0' | |
| 158 # Skip empty lines | 158 # Skip empty lines |
| 159 l = l.strip() | 159 l = l.strip() |
| 160 if not l: | 160 if not l: |
| 161 continue | 161 continue |
| 162 # XXX: Does this always follow Python escape semantics? | 162 # XXX: Does this always follow Python escape semantics? |
