X Tutup
Skip to content

Commit 2c841a8

Browse files
committed
Use plural strings
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent e5e6bd8 commit 2c841a8

File tree

8 files changed

+98
-122
lines changed

8 files changed

+98
-122
lines changed

bpython/repl.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from bpython import inspection
4949
from bpython._py3compat import PythonLexer, py3
5050
from bpython.formatter import Parenthesis
51-
from bpython.translations import _
51+
from bpython.translations import _, ngettext
5252
from bpython.clipboard import get_clipboard, CopyFailed
5353
from bpython.history import History
5454
import bpython.autocomplete as autocomplete
@@ -666,7 +666,6 @@ def write2file(self):
666666
if os.path.exists(fn):
667667
mode = self.interact.file_prompt(_('%s already exists. Do you '
668668
'want to (c)ancel, '
669-
'wantch to (c)ancel, '
670669
' (o)verwrite or '
671670
'(a)ppend? ') % (fn, ))
672671
if mode in ('o', 'overwrite', _('overwrite')):
@@ -850,12 +849,10 @@ def prompt_undo(self):
850849
if n == 0:
851850
self.interact.notify(_('Undo canceled'), .1)
852851
return 0
853-
if n == 1:
854-
self.interact.notify(_('Undoing 1 line... (est. %.1f seconds)')
855-
% (est,), .1)
856852
else:
857-
self.interact.notify(_('Undoing %d lines... (est. %.1f seconds)')
858-
% (n, est), .1)
853+
message = ngettext('Undoing %d line... (est. %.1f seconds)',
854+
'Undoing %d lines... (est. %.1f seconds)', n)
855+
self.interact.notify(message % (n, est), .1)
859856
return n
860857

861858
def undo(self, n=1):
@@ -994,7 +991,8 @@ def clear_current_line(self):
994991
It prevents autoindentation from occuring after a traceback."""
995992

996993
def send_to_external_editor(self, text, filename=None):
997-
"""Returns modified text from an editor, or the oriignal text if editor exited with non-zero"""
994+
"""Returns modified text from an editor, or the oriignal text if editor
995+
exited with non-zero"""
998996
editor_args = shlex.split(self.config.editor)
999997
with tempfile.NamedTemporaryFile(suffix='.py') as temp:
1000998
temp.write(text.encode(getpreferredencoding()))

bpython/translations/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
if py3:
1212
def _(message):
1313
return translator.gettext(message)
14+
15+
def ngettext(singular, plural, n):
16+
return translator.ngettext(singular, plural, n)
1417
else:
1518
def _(message):
1619
return translator.ugettext(message)
1720

21+
def ngettext(singular, plural, n):
22+
return translator.ungettext(singular, plural, n)
1823

1924
def init(locale_dir=None, languages=None):
2025
try:

bpython/translations/bpython.pot

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#, fuzzy
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: bpython 0.13-492\n"
9+
"Project-Id-Version: bpython 0.13-493\n"
1010
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11-
"POT-Creation-Date: 2015-02-01 23:02+0100\n"
11+
"POT-Creation-Date: 2015-02-02 00:30+0100\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -121,7 +121,7 @@ msgstr ""
121121
msgid "append"
122122
msgstr ""
123123

124-
#: bpython/repl.py:685 bpython/repl.py:1028
124+
#: bpython/repl.py:685 bpython/repl.py:1027
125125
#, python-format
126126
msgid "Error writing file '%s': %s"
127127
msgstr ""
@@ -207,23 +207,20 @@ msgstr ""
207207

208208
#: bpython/repl.py:853
209209
#, python-format
210-
msgid "Undoing 1 line... (est. %.1f seconds)"
211-
msgstr ""
212-
213-
#: bpython/repl.py:856
214-
#, python-format
215-
msgid "Undoing %d lines... (est. %.1f seconds)"
216-
msgstr ""
210+
msgid "Undoing %d line... (est. %.1f seconds)"
211+
msgid_plural "Undoing %d lines... (est. %.1f seconds)"
212+
msgstr[0] ""
213+
msgstr[1] ""
217214

218-
#: bpython/repl.py:1018
215+
#: bpython/repl.py:1017
219216
msgid "Config file does not exist - create new from default? (y/N)"
220217
msgstr ""
221218

222-
#: bpython/repl.py:1035
219+
#: bpython/repl.py:1034
223220
msgid "bpython config file edited. Restart bpython for changes to take effect."
224221
msgstr ""
225222

226-
#: bpython/repl.py:1038
223+
#: bpython/repl.py:1037
227224
msgid "Error editing config file."
228225
msgstr ""
229226

bpython/translations/de/LC_MESSAGES/bpython.po

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: bpython mercurial\n"
99
"Report-Msgid-Bugs-To: http://github.com/bpython/bpython/issues\n"
10-
"POT-Creation-Date: 2015-02-01 23:02+0100\n"
11-
"PO-Revision-Date: 2015-02-01 23:02+0100\n"
10+
"POT-Creation-Date: 2015-02-02 00:30+0100\n"
11+
"PO-Revision-Date: 2015-02-02 00:31+0100\n"
1212
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
1313
"Language-Team: de <LL@li.org>\n"
14-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
14+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
1818
"Generated-By: Babel 1.3\n"
19-
"Language: de\n"
20-
"X-Generator: Poedit 1.6.10\n"
2119

2220
#: bpython/args.py:57
2321
msgid ""
2422
"Usage: %prog [options] [file [args]]\n"
25-
"NOTE: If bpython sees an argument it does not know, execution falls back to "
26-
"the regular Python interpreter."
23+
"NOTE: If bpython sees an argument it does not know, execution falls back "
24+
"to the regular Python interpreter."
2725
msgstr ""
2826

2927
#: bpython/args.py:67
@@ -113,8 +111,7 @@ msgstr "Speichern abgebrochen."
113111
#: bpython/repl.py:667
114112
#, python-format
115113
msgid "%s already exists. Do you want to (c)ancel, (o)verwrite or (a)ppend? "
116-
msgstr ""
117-
"%s existiert bereit. (C) abbrechen, (o) überschrieben oder (a) anhängen?"
114+
msgstr "%s existiert bereit. (C) abbrechen, (o) überschrieben oder (a) anhängen?"
118115

119116
#: bpython/repl.py:671
120117
msgid "overwrite"
@@ -124,7 +121,7 @@ msgstr "überschreiben"
124121
msgid "append"
125122
msgstr "anhängen"
126123

127-
#: bpython/repl.py:685 bpython/repl.py:1028
124+
#: bpython/repl.py:685 bpython/repl.py:1027
128125
#, python-format
129126
msgid "Error writing file '%s': %s"
130127
msgstr "Fehler beim Schreiben in Datei '%s': %s"
@@ -175,13 +172,13 @@ msgstr ""
175172

176173
#: bpython/repl.py:779
177174
msgid "Upload failed: Helper program not found."
178-
msgstr ""
179-
"Hochladen ist fehlgeschlagen: Hilfsprogramm konnte nicht gefunden werden."
175+
msgstr "Hochladen ist fehlgeschlagen: Hilfsprogramm konnte nicht gefunden werden."
180176

181177
#: bpython/repl.py:782
182178
msgid "Upload failed: Helper program could not be run."
183179
msgstr ""
184-
"Hochladen ist fehlgeschlagen: Hilfsprogramm konnte nicht ausgeführt werden."
180+
"Hochladen ist fehlgeschlagen: Hilfsprogramm konnte nicht ausgeführt "
181+
"werden."
185182

186183
#: bpython/repl.py:789
187184
#, python-format
@@ -190,12 +187,10 @@ msgstr "Hochladen ist fehlgeschlagen: Hilfsprogramm beendete mit Status %s."
190187

191188
#: bpython/repl.py:793
192189
msgid "Upload failed: No output from helper program."
193-
msgstr ""
194-
"Hochladen ist fehlgeschlagen: Keine Ausgabe von Hilfsprogramm vorhanden."
190+
msgstr "Hochladen ist fehlgeschlagen: Keine Ausgabe von Hilfsprogramm vorhanden."
195191

196192
#: bpython/repl.py:800
197-
msgid ""
198-
"Upload failed: Failed to recognize the helper program's output as an URL."
193+
msgid "Upload failed: Failed to recognize the helper program's output as an URL."
199194
msgstr ""
200195
"Hochladen ist fehlgeschlagen: Konte Ausgabe von Hilfsprogramm nicht "
201196
"verarbeiten."
@@ -216,27 +211,24 @@ msgstr "Rückgängigmachen abgebrochen"
216211

217212
#: bpython/repl.py:853
218213
#, python-format
219-
msgid "Undoing 1 line... (est. %.1f seconds)"
220-
msgstr ""
221-
222-
#: bpython/repl.py:856
223-
#, python-format
224-
msgid "Undoing %d lines... (est. %.1f seconds)"
225-
msgstr ""
214+
msgid "Undoing %d line... (est. %.1f seconds)"
215+
msgid_plural "Undoing %d lines... (est. %.1f seconds)"
216+
msgstr[0] ""
217+
msgstr[1] ""
226218

227-
#: bpython/repl.py:1018
219+
#: bpython/repl.py:1017
228220
msgid "Config file does not exist - create new from default? (y/N)"
229221
msgstr ""
230-
"Konfigurationsdatei existiert nicht. Soll eine neue Datei erstellt werden? "
231-
"(j/N)"
222+
"Konfigurationsdatei existiert nicht. Soll eine neue Datei erstellt "
223+
"werden? (j/N)"
232224

233-
#: bpython/repl.py:1035
225+
#: bpython/repl.py:1034
234226
msgid "bpython config file edited. Restart bpython for changes to take effect."
235227
msgstr ""
236228
"bpython Konfigurationsdatei bearbeitet. Starte bpython neu damit die "
237229
"Änderungen übernommen werden."
238230

239-
#: bpython/repl.py:1038
231+
#: bpython/repl.py:1037
240232
msgid "Error editing config file."
241233
msgstr "Fehler beim Bearbeiten der Konfigurationsdatei."
242234

bpython/translations/es_ES/LC_MESSAGES/bpython.po

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: bpython 0.9.7\n"
99
"Report-Msgid-Bugs-To: http://github.com/bpython/bpython/issues\n"
10-
"POT-Creation-Date: 2015-02-01 23:02+0100\n"
11-
"PO-Revision-Date: 2015-02-01 23:04+0100\n"
10+
"POT-Creation-Date: 2015-02-02 00:30+0100\n"
11+
"PO-Revision-Date: 2015-02-02 00:31+0100\n"
1212
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
1313
"Language-Team: bpython developers\n"
1414
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
@@ -121,7 +121,7 @@ msgstr ""
121121
msgid "append"
122122
msgstr ""
123123

124-
#: bpython/repl.py:685 bpython/repl.py:1028
124+
#: bpython/repl.py:685 bpython/repl.py:1027
125125
#, python-format
126126
msgid "Error writing file '%s': %s"
127127
msgstr ""
@@ -207,23 +207,20 @@ msgstr ""
207207

208208
#: bpython/repl.py:853
209209
#, python-format
210-
msgid "Undoing 1 line... (est. %.1f seconds)"
211-
msgstr ""
212-
213-
#: bpython/repl.py:856
214-
#, python-format
215-
msgid "Undoing %d lines... (est. %.1f seconds)"
216-
msgstr ""
210+
msgid "Undoing %d line... (est. %.1f seconds)"
211+
msgid_plural "Undoing %d lines... (est. %.1f seconds)"
212+
msgstr[0] ""
213+
msgstr[1] ""
217214

218-
#: bpython/repl.py:1018
215+
#: bpython/repl.py:1017
219216
msgid "Config file does not exist - create new from default? (y/N)"
220217
msgstr ""
221218

222-
#: bpython/repl.py:1035
219+
#: bpython/repl.py:1034
223220
msgid "bpython config file edited. Restart bpython for changes to take effect."
224221
msgstr ""
225222

226-
#: bpython/repl.py:1038
223+
#: bpython/repl.py:1037
227224
msgid "Error editing config file."
228225
msgstr ""
229226

0 commit comments

Comments
 (0)
X Tutup