http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11316
Revision: 11316
Author: siebrand
Date: 2013-04-01 13:09:37 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
Localisation updates from http://translatewiki.net.
Modified Paths:
--------------
branches/rewrite/scripts/i18n/redirect.py
branches/rewrite/scripts/i18n/weblinkchecker.py
Modified: branches/rewrite/scripts/i18n/redirect.py
===================================================================
--- branches/rewrite/scripts/i18n/redirect.py 2013-04-01 12:24:19 UTC (rev 11315)
+++ branches/rewrite/scripts/i18n/redirect.py 2013-04-01 13:09:37 UTC (rev 11316)
@@ -308,9 +308,11 @@
# Author: Nedergard
# Author: Nike
# Author: Olli
+ # Author: Silvonen
'fi': {
'redirect-fix-double': u'Botti korjasi kaksinkertaisen ohjauksen sivulle %(to)s',
'redirect-remove-broken': u'Botti: Ohjaus poistetulle tai olemattomalle sivulle',
+ 'redirect-fix-broken-moved': u'Botti korjasi rikkinäisen ohjauksen siirrettyyn kohdesivuun %(to)s',
'redirect-fix-loop': u'Botti korjasi ohjaussilmukan sivulle %(to)s',
'redirect-remove-loop': u'Botti: Ohjauksen kohde muodostaa ohjaussilmukan',
'redirect-broken-redirect-template': u'{{Delete}}',
Modified: branches/rewrite/scripts/i18n/weblinkchecker.py
===================================================================
--- branches/rewrite/scripts/i18n/weblinkchecker.py 2013-04-01 12:24:19 UTC (rev 11315)
+++ branches/rewrite/scripts/i18n/weblinkchecker.py 2013-04-01 13:09:37 UTC (rev 11316)
@@ -53,6 +53,13 @@
'weblinkchecker-summary': u'Robot: Informant d\'un enllaç extern inaccessible',
'weblinkchecker-report': u'Durant diverses execucions automàtiques, el bot ha comprovat que el següent enllaç extern no està disponible. Comproveu que l\'enllaç estigui realment trencat i corregiu-lo o retireu-lo.!',
},
+ # Author: Tchoř
+ 'cs': {
+ 'weblinkchecker-archive_msg': u'Webová stránka je uložena v projektu Internet Archive. Prosím zvažte, zda neodkázat na patřičnou archivovanou verzi [%(URL)s].',
+ 'weblinkchecker-caption': u'Mrtvý odkaz',
+ 'weblinkchecker-summary': u'Robot: Ohlašuji nedostupný externí odkaz.',
+ 'weblinkchecker-report': u'Během několika automatizovaných běhů byl následující externí odkaz nedostupný. Prosím, ověřte, zda je skutečně nedostupný, a pokud ano, pak jej opravte nebo odstraňte!',
+ },
# Author: Steenth
'da': {
'weblinkchecker-archive_msg': u'Websiden er blevet gemt af Internet Archive. Overvej sammenkædning til en passende arkiverede version: [%(URL)s].',
@@ -73,8 +80,9 @@
'weblinkchecker-report': u'Bei mehreren automatisierten Botläufen wurde die folgende Verknüpfung als nicht verfügbar erkannt. Bitte überprüfe, ob die Verknüpfung tatsächlich nicht erreichbar ist, und korrigiere oder entferne sie in diesem Fall!',
},
# Author: Gorizon
+ # Author: Mirzali
'diq': {
- 'weblinkchecker-caption': u'Greyo merde',
+ 'weblinkchecker-caption': u'Gıreyo merde',
},
# Author: Airon90
'eo': {
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11315
Revision: 11315
Author: xqt
Date: 2013-04-01 12:24:19 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
use PLURAL support from translate() method
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2013-04-01 10:53:12 UTC (rev 11314)
+++ trunk/pywikipedia/checkimages.py 2013-04-01 12:24:19 UTC (rev 11315)
@@ -1468,11 +1468,11 @@
skip_number = limit
# Print a starting message only if no images has been skipped
if not self.skip_list:
- if skip_number == 1:
- pywikibot.output(u'Skipping the first file:\n')
- else:
- pywikibot.output(u'Skipping the first %s files:\n'
- % skip_number)
+ pywikibot.output(
+ pywikibot.translate(
+ 'en',
+ u'Skipping the first {{PLURAL:num|file|%(num)s files}}:\n',
+ {'num': skip_number})
# If we still have pages to skip:
if len(self.skip_list) < skip_number:
pywikibot.output(u'Skipping %s...' % self.imageName)
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11314
Revision: 11314
Author: xqt
Date: 2013-04-01 10:53:12 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
PLURAL support for pywikibot.translate() method.
For additional help please refer pywikibot.twntranslate()
update from trunk r11312
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2013-04-01 10:52:18 UTC (rev 11313)
+++ branches/rewrite/pywikibot/i18n.py 2013-04-01 10:53:12 UTC (rev 11314)
@@ -3,7 +3,7 @@
and for TranslateWiki-based translations
"""
#
-# (C) Pywikipedia bot team, 2004-2012
+# (C) Pywikipedia bot team, 2004-2013
#
# Distributed under the terms of the MIT license.
#
@@ -16,22 +16,25 @@
import pywikibot
import config2 as config
-# Languages to use for comment text after the actual language but before
-# en:. For example, if for language 'xx', you want the preference of
-# languages to be:
-# xx:, then fr:, then ru:, then en:
-# you let altlang return ['fr','ru'].
-# This code is used by translate() and twtranslate() below.
+PLURAL_PATTERN = '{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
+
def _altlang(code):
"""Define fallback languages for particular languages.
+ @param code The language code
+ @type code string
+ @return a list of strings as language codes
+
If no translation is available to a specified language, translate() will
try each of the specified fallback languages, in order, until it finds
one with a translation, with 'en' and '_default' as a last resort.
For example, if for language 'xx', you want the preference of languages
to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
+
+ This code is used by other translating methods below.
+
"""
#Akan
if code in ['ak', 'tw']:
@@ -65,7 +68,7 @@
return ['de', 'pl']
if code == 'rm':
return ['de', 'it']
- if code =='stq':
+ if code == 'stq':
return ['nds', 'de']
#Greek
if code in ['grc', 'pnt']:
@@ -74,7 +77,8 @@
if code in ['io', 'nov']:
return ['eo']
#Spanish
- if code in ['an', 'arn', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu', 'yua']:
+ if code in ['an', 'arn', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu',
+ 'yua']:
return ['es']
if code in ['gl', 'gn']:
return ['es', 'pt']
@@ -145,9 +149,9 @@
if code in ['mo', 'roa-rup']:
return ['ro']
#Russian and Belarusian
- if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'inh', 'kk', 'koi', 'krc', 'kv',
- 'ky', 'lbe', 'lez', 'mdf', 'mhr', 'mn', 'mrj', 'myv', 'os', 'sah',
- 'tg', 'udm', 'uk', 'xal']:
+ if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'inh', 'kk', 'koi', 'krc',
+ 'kv', 'ky', 'lbe', 'lez', 'mdf', 'mhr', 'mn', 'mrj', 'myv',
+ 'os', 'sah', 'tg', 'udm', 'uk', 'xal']:
return ['ru']
if code in ['kbd', 'ady']:
return ['kbd', 'ady', 'ru']
@@ -158,7 +162,7 @@
if code == 'kaa':
return ['uz', 'ru']
#Serbocroatian
- if code in ['bs', 'hr', 'sh',]:
+ if code in ['bs', 'hr', 'sh']:
return ['sh', 'hr', 'bs', 'sr', 'sr-el']
if code == 'sr':
return ['sr-el', 'sh', 'hr', 'bs']
@@ -213,9 +217,27 @@
#Default value
return []
-def translate(code, xdict, fallback=True):
+
+class TranslationError(Error):
+ """ Raised when no correct translation could be found """
+ pass
+
+
+def translate(code, xdict, parameters=None, fallback=True):
"""Return the most appropriate translation from a translation dict.
+ @param code The language code
+ @type code string or Site object
+ @param xdict dictionary with language codes as keys or extended dictionary
+ with family names as keys containing language dictionaries or
+ a single (unicode) string. May contain PLURAL tags as described
+ in twntranslate
+ @type xdict dict, string, unicode
+ @param parameters For passing (plural) parameters
+ @type parameters dict, string, unicode, int
+ @param fallback Try an alternate language code
+ @type fallback boolean
+
Given a language code and a dictionary, returns the dictionary's value for
key 'code' if this key exists; otherwise tries to return a value for an
alternative language that is most applicable to use on the Wikipedia in
@@ -226,7 +248,13 @@
the options gives result, we just take the first language in the
list.
+ For PLURAL support have a look at the twntranslate method
+
"""
+ param = None
+ if type(parameters) == dict:
+ param = parameters
+
family = pywikibot.config.family
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
@@ -238,27 +266,56 @@
xdict = xdict[family]
elif 'wikipedia' in xdict:
xdict = xdict['wikipedia']
+
+ # Get the translated string
+ trans = None
if type(xdict) != dict:
- return xdict
+ trans = xdict
+ elif code in xdict:
+ trans = xdict[code]
+ elif fallback:
+ for alt in _altlang(code) + ['_default', 'en']:
+ if alt in xdict:
+ trans = xdict[alt]
+ break
+ else:
+ trans = xdict.values()[0]
+ if not trans:
+ return # return None if we have no translation found
+ if parameters is None:
+ return trans
- if code in xdict:
- return xdict[code]
- if not fallback:
- return None
- for alt in _altlang(code):
- if alt in xdict:
- return xdict[alt]
- if '_default' in xdict:
- return xdict['_default']
- if 'en' in xdict:
- return xdict['en']
- return xdict.values()[0]
+ # else we check for PLURAL variants
+ try:
+ selector, variants = re.search(PLURAL_PATTERN, trans).groups()
+ except AttributeError:
+ pass
+ else: # we found PLURAL patterns, process it
+ if type(parameters) == dict:
+ num = param[selector]
+ elif isinstance(parameters, basestring):
+ num = int(parameters)
+ else:
+ num = parameters
+ # we only need the lang or _default, not a _altlang code
+ # TODO: check against plural_rules[lang]['nplurals']
+ try:
+ index = plural_rules[code]['plural'](num)
+ except KeyError:
+ index = plural_rules['_default']['plural'](num)
+ except TypeError:
+ # we got an int, not a function
+ index = plural_rules[code]['plural']
+ trans = re.sub(PLURAL_PATTERN, variants.split('|')[index], trans)
+ if param:
+ try:
+ return trans % param
+ except KeyError:
+ # parameter is for PLURAL variants only, don't change the string
+ pass
+ return trans
-class TranslationError(Error):
- """ Raised when no correct translation could be found """
- pass
-
def twtranslate(code, twtitle, parameters=None):
""" Uses TranslateWiki files to provide translations based on the TW title
twtitle, which corresponds to a page on TW.
@@ -302,7 +359,8 @@
except KeyError:
continue
if not trans:
- raise TranslationError("No English translation has been defined for TranslateWiki key %r" % twtitle)
+ raise TranslationError("No English translation has been defined "
+ "for TranslateWiki key %r" % twtitle)
# send the language code back via the given list
if code_needed:
code.append(lang)
@@ -311,6 +369,7 @@
else:
return trans
+
# Maybe this function should be merged with twtranslate
def twntranslate(code, twtitle, parameters=None):
""" First implementation of plural support for translations based on the
@@ -363,8 +422,8 @@
The translations are retrieved from i18n.<package>, based on the callers
import table.
+
"""
- PATTERN = '{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
param = None
if type(parameters) == dict:
param = parameters
@@ -375,14 +434,14 @@
code = [code]
trans = twtranslate(code, twtitle, None)
try:
- selector, variants = re.search(PATTERN, trans).groups()
+ selector, variants = re.search(PLURAL_PATTERN, trans).groups()
# No PLURAL tag found: nothing to replace
except AttributeError:
pass
else:
if type(parameters) == dict:
num = param[selector]
- elif type(parameters) == basestring:
+ elif isinstance(parameters, basestring):
num = int(parameters)
else:
num = parameters
@@ -399,7 +458,7 @@
# we got an int
index = plural_rules[lang]['plural']
repl = variants.split('|')[index]
- trans = re.sub(PATTERN, repl, trans)
+ trans = re.sub(PLURAL_PATTERN, repl, trans)
if param:
try:
return trans % param
@@ -407,6 +466,7 @@
pass
return trans
+
def twhas_key(code, twtitle):
""" Uses TranslateWiki files to to check whether specified translation
based on the TW title is provided. No code fallback is made.
@@ -424,6 +484,7 @@
code = code.lang
return code in transdict and twtitle in transdict[code]
+
def input(twtitle, parameters=None, password=False):
""" Ask the user a question, return the user's answer.
@param twtitle The TranslateWiki string title, in <package>-<key> format
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11313
Revision: 11313
Author: xqt
Date: 2013-04-01 10:52:18 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
remove debugging stuff;
fix for pre 2.5 code
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2013-04-01 10:37:24 UTC (rev 11312)
+++ trunk/pywikipedia/pywikibot/i18n.py 2013-04-01 10:52:18 UTC (rev 11313)
@@ -304,14 +304,11 @@
# TODO: check against plural_rules[lang]['nplurals']
try:
index = plural_rules[code]['plural'](num)
- print 1, num, index
except KeyError:
index = plural_rules['_default']['plural'](num)
- print 2, num, index
except TypeError:
# we got an int, not a function
index = plural_rules[code]['plural']
- print 3, index
trans = re.sub(PLURAL_PATTERN, variants.split('|')[index], trans)
if param:
try:
@@ -457,6 +454,7 @@
# to use plural.py - use _default rules for all
if sys.version_info < (2, 5):
plural_func = lambda n: (n != 1)
+ index = plural_rules(num)
else:
from plural import plural_rules
# we only need the lang or _default, not a _altlang code
@@ -467,7 +465,7 @@
except KeyError:
index = plural_rules['_default']['plural'](num)
except TypeError:
- # we got an int
+ # we got an int not a function
index = plural_rules[lang]['plural']
repl = variants.split('|')[index]
trans = re.sub(PLURAL_PATTERN, repl, trans)
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11312
Revision: 11312
Author: xqt
Date: 2013-04-01 10:37:24 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
PLURAL support for pywikibot.translate() method.
For additional help please refer pywikibot.twntranslate()
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2013-03-31 17:05:13 UTC (rev 11311)
+++ trunk/pywikipedia/pywikibot/i18n.py 2013-04-01 10:37:24 UTC (rev 11312)
@@ -3,34 +3,38 @@
and for TranslateWiki-based translations
"""
#
-# (C) Pywikipedia bot team, 2004-2012
+# (C) Pywikipedia bot team, 2004-2013
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
-import re, sys
+import re
+import sys
import locale
from pywikibot.exceptions import Error
import wikipedia as pywikibot
import config
-# Languages to use for comment text after the actual language but before
-# en:. For example, if for language 'xx', you want the preference of
-# languages to be:
-# xx:, then fr:, then ru:, then en:
-# you let altlang return ['fr','ru'].
-# This code is used by translate() and twtranslate() below.
+PLURAL_PATTERN = '{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
+
def _altlang(code):
"""Define fallback languages for particular languages.
+ @param code The language code
+ @type code string
+ @return a list of strings as language codes
+
If no translation is available to a specified language, translate() will
try each of the specified fallback languages, in order, until it finds
one with a translation, with 'en' and '_default' as a last resort.
For example, if for language 'xx', you want the preference of languages
to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
+
+ This code is used by other translating methods below.
+
"""
#Akan
if code in ['ak', 'tw']:
@@ -64,7 +68,7 @@
return ['de', 'pl']
if code == 'rm':
return ['de', 'it']
- if code =='stq':
+ if code == 'stq':
return ['nds', 'de']
#Greek
if code in ['grc', 'pnt']:
@@ -73,7 +77,8 @@
if code in ['io', 'nov']:
return ['eo']
#Spanish
- if code in ['an', 'arn', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu', 'yua']:
+ if code in ['an', 'arn', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu',
+ 'yua']:
return ['es']
if code in ['gl', 'gn']:
return ['es', 'pt']
@@ -144,9 +149,9 @@
if code in ['mo', 'roa-rup']:
return ['ro']
#Russian and Belarusian
- if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'inh', 'kk', 'koi', 'krc', 'kv',
- 'ky', 'lbe', 'lez', 'mdf', 'mhr', 'mn', 'mrj', 'myv', 'os', 'sah',
- 'tg', 'udm', 'uk', 'xal']:
+ if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'inh', 'kk', 'koi', 'krc',
+ 'kv', 'ky', 'lbe', 'lez', 'mdf', 'mhr', 'mn', 'mrj', 'myv',
+ 'os', 'sah', 'tg', 'udm', 'uk', 'xal']:
return ['ru']
if code in ['kbd', 'ady']:
return ['kbd', 'ady', 'ru']
@@ -157,7 +162,7 @@
if code == 'kaa':
return ['uz', 'ru']
#Serbocroatian
- if code in ['bs', 'hr', 'sh',]:
+ if code in ['bs', 'hr', 'sh']:
return ['sh', 'hr', 'bs', 'sr', 'sr-el']
if code == 'sr':
return ['sr-el', 'sh', 'hr', 'bs']
@@ -212,9 +217,27 @@
#Default value
return []
-def translate(code, xdict, fallback=True):
+
+class TranslationError(Error):
+ """ Raised when no correct translation could be found """
+ pass
+
+
+def translate(code, xdict, parameters=None, fallback=True):
"""Return the most appropriate translation from a translation dict.
+ @param code The language code
+ @type code string or Site object
+ @param xdict dictionary with language codes as keys or extended dictionary
+ with family names as keys containing language dictionaries or
+ a single (unicode) string. May contain PLURAL tags as described
+ in twntranslate
+ @type xdict dict, string, unicode
+ @param parameters For passing (plural) parameters
+ @type parameters dict, string, unicode, int
+ @param fallback Try an alternate language code
+ @type fallback boolean
+
Given a language code and a dictionary, returns the dictionary's value for
key 'code' if this key exists; otherwise tries to return a value for an
alternative language that is most applicable to use on the Wikipedia in
@@ -225,7 +248,13 @@
the options gives result, we just take the first language in the
list.
+ For PLURAL support have a look at the twntranslate method
+
"""
+ param = None
+ if type(parameters) == dict:
+ param = parameters
+
family = pywikibot.default_family
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
@@ -237,27 +266,62 @@
xdict = xdict[family]
elif 'wikipedia' in xdict:
xdict = xdict['wikipedia']
+
+ # Get the translated string
+ trans = None
if type(xdict) != dict:
- return xdict
+ trans = xdict
+ elif code in xdict:
+ trans = xdict[code]
+ elif fallback:
+ for alt in _altlang(code) + ['_default', 'en']:
+ if alt in xdict:
+ trans = xdict[alt]
+ break
+ else:
+ trans = xdict.values()[0]
+ if not trans:
+ return # return None if we have no translation found
+ if parameters is None:
+ return trans
- if code in xdict:
- return xdict[code]
- if not fallback:
- return None
- for alt in _altlang(code):
- if alt in xdict:
- return xdict[alt]
- if '_default' in xdict:
- return xdict['_default']
- if 'en' in xdict:
- return xdict['en']
- return xdict.values()[0]
+ # else we check for PLURAL variants
+ try:
+ selector, variants = re.search(PLURAL_PATTERN, trans).groups()
+ except AttributeError:
+ pass
+ else: # we found PLURAL patterns, process it
+ # no python 2.5 support anymore but we won't break old code
+ # therefore we import plural_rules here
+ from plural import plural_rules
+ if type(parameters) == dict:
+ num = param[selector]
+ elif isinstance(parameters, basestring):
+ num = int(parameters)
+ else:
+ num = parameters
+ # we only need the lang or _default, not a _altlang code
+ # TODO: check against plural_rules[lang]['nplurals']
+ try:
+ index = plural_rules[code]['plural'](num)
+ print 1, num, index
+ except KeyError:
+ index = plural_rules['_default']['plural'](num)
+ print 2, num, index
+ except TypeError:
+ # we got an int, not a function
+ index = plural_rules[code]['plural']
+ print 3, index
+ trans = re.sub(PLURAL_PATTERN, variants.split('|')[index], trans)
+ if param:
+ try:
+ return trans % param
+ except KeyError:
+ # parameter is for PLURAL variants only, don't change the string
+ pass
+ return trans
-class TranslationError(Error):
- """ Raised when no correct translation could be found """
- pass
-
def twtranslate(code, twtitle, parameters=None):
""" Uses TranslateWiki files to provide translations based on the TW title
twtitle, which corresponds to a page on TW.
@@ -301,7 +365,8 @@
except KeyError:
continue
if not trans:
- raise TranslationError("No English translation has been defined for TranslateWiki key %r" % twtitle)
+ raise TranslationError("No English translation has been defined "
+ "for TranslateWiki key %r" % twtitle)
# send the language code back via the given list
if code_needed:
code.append(lang)
@@ -310,6 +375,7 @@
else:
return trans
+
# Maybe this function should be merged with twtranslate
def twntranslate(code, twtitle, parameters=None):
""" First implementation of plural support for translations based on the
@@ -362,8 +428,8 @@
The translations are retrieved from i18n.<package>, based on the callers
import table.
+
"""
- PATTERN = '{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
param = None
if type(parameters) == dict:
param = parameters
@@ -374,14 +440,14 @@
code = [code]
trans = twtranslate(code, twtitle, None)
try:
- selector, variants = re.search(PATTERN, trans).groups()
+ selector, variants = re.search(PLURAL_PATTERN, trans).groups()
# No PLURAL tag found: nothing to replace
except AttributeError:
pass
else:
if type(parameters) == dict:
num = param[selector]
- elif type(parameters) == basestring:
+ elif isinstance(parameters, basestring):
num = int(parameters)
else:
num = parameters
@@ -391,7 +457,7 @@
# to use plural.py - use _default rules for all
if sys.version_info < (2, 5):
plural_func = lambda n: (n != 1)
- else:
+ else:
from plural import plural_rules
# we only need the lang or _default, not a _altlang code
# maybe we should implement this to i18n.translate()
@@ -404,7 +470,7 @@
# we got an int
index = plural_rules[lang]['plural']
repl = variants.split('|')[index]
- trans = re.sub(PATTERN, repl, trans)
+ trans = re.sub(PLURAL_PATTERN, repl, trans)
if param:
try:
return trans % param
@@ -412,6 +478,7 @@
pass
return trans
+
def twhas_key(code, twtitle):
""" Uses TranslateWiki files to to check whether specified translation
based on the TW title is provided. No code fallback is made.
@@ -429,6 +496,7 @@
code = code.lang
return code in transdict and twtitle in transdict[code]
+
def input(twtitle, parameters=None, password=False):
""" Ask the user a question, return the user's answer.
@param twtitle The TranslateWiki string title, in <package>-<key> format