Merge branch 'i18n' into l10n-fr

This commit is contained in:
Valentin Lorentz 2010-10-29 12:03:16 +02:00
commit 28787c77dd
4 changed files with 87 additions and 50 deletions

View File

@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-10-17 16:36+CEST\n" "POT-Creation-Date: 2010-10-29 12:02+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -28,38 +28,38 @@ msgid ""
" when the 'most' command is called." " when the 'most' command is called."
msgstr "" msgstr ""
#: plugin.py:293 #: plugin.py:292
#, docstring #, docstring
msgid "" msgid ""
"Add the help for \"@help MoobotFactoids\" here (assuming you don't implement a MoobotFactoids\n" "Add the help for \"@help MoobotFactoids\" here (assuming you don't implement a MoobotFactoids\n"
" command). This should describe *how* to use this plugin." " command). This should describe *how* to use this plugin."
msgstr "" msgstr ""
#: plugin.py:350 #: plugin.py:349
msgid "%s is %s" msgid "%s is %s"
msgstr "" msgstr ""
#: plugin.py:369 #: plugin.py:368
msgid "Factoid %q is locked." msgid "Factoid %q is locked."
msgstr "" msgstr ""
#: plugin.py:376 #: plugin.py:375
msgid "Factoid %q not found." msgid "Factoid %q not found."
msgstr "" msgstr ""
#: plugin.py:386 #: plugin.py:385
msgid "Missing an 'is' or '_is_'." msgid "Missing an 'is' or '_is_'."
msgstr "" msgstr ""
#: plugin.py:402 #: plugin.py:401
msgid "Factoid %q already exists." msgid "Factoid %q already exists."
msgstr "" msgstr ""
#: plugin.py:436 #: plugin.py:435
msgid "%s, or %s" msgid "%s, or %s"
msgstr "" msgstr ""
#: plugin.py:457 #: plugin.py:456
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <factoid key>\n" "[<channel>] <factoid key>\n"
@ -70,7 +70,7 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:470 #: plugin.py:469
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <factoid key>\n" "[<channel>] <factoid key>\n"
@ -81,39 +81,39 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:481 plugin.py:521 #: plugin.py:480 plugin.py:520
msgid "No such factoid: %q" msgid "No such factoid: %q"
msgstr "" msgstr ""
#: plugin.py:490 #: plugin.py:489
msgid "Created by %s on %s." msgid "Created by %s on %s."
msgstr "" msgstr ""
#: plugin.py:496 #: plugin.py:495
msgid " Last modified by %s on %s." msgid " Last modified by %s on %s."
msgstr "" msgstr ""
#: plugin.py:504 #: plugin.py:503
msgid " Last requested by %s on %s, requested %n." msgid " Last requested by %s on %s, requested %n."
msgstr "" msgstr ""
#: plugin.py:511 #: plugin.py:510
msgid " Locked by %s on %s." msgid " Locked by %s on %s."
msgstr "" msgstr ""
#: plugin.py:526 #: plugin.py:525
msgid "Factoid %q is already locked." msgid "Factoid %q is already locked."
msgstr "" msgstr ""
#: plugin.py:529 #: plugin.py:528
msgid "Factoid %q is not locked." msgid "Factoid %q is not locked."
msgstr "" msgstr ""
#: plugin.py:539 #: plugin.py:538
msgid "Cannot %s someone else's factoid unless you are an admin." msgid "Cannot %s someone else's factoid unless you are an admin."
msgstr "" msgstr ""
#: plugin.py:551 #: plugin.py:550
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <factoid key>\n" "[<channel>] <factoid key>\n"
@ -124,7 +124,7 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:562 #: plugin.py:561
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <factoid key>\n" "[<channel>] <factoid key>\n"
@ -135,7 +135,7 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:573 #: plugin.py:572
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] {popular|authored|recent}\n" "[<channel>] {popular|authored|recent}\n"
@ -148,43 +148,51 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:598 #: plugin.py:594
msgid "author"
msgstr ""
#: plugin.py:596
msgid "authors"
msgstr ""
#: plugin.py:597
msgid "Most prolific %s: %L" msgid "Most prolific %s: %L"
msgstr "" msgstr ""
#: plugin.py:600 plugin.py:612 #: plugin.py:599 plugin.py:611
msgid "There are no factoids in my database." msgid "There are no factoids in my database."
msgstr "" msgstr ""
#: plugin.py:607 #: plugin.py:606
msgid "latest factoid" msgid "latest factoid"
msgstr "" msgstr ""
#: plugin.py:609 #: plugin.py:608
msgid "latest factoids" msgid "latest factoids"
msgstr "" msgstr ""
#: plugin.py:610 #: plugin.py:609
msgid "%s: %L" msgid "%s: %L"
msgstr "" msgstr ""
#: plugin.py:619 #: plugin.py:618
msgid "requested factoid" msgid "requested factoid"
msgstr "" msgstr ""
#: plugin.py:621 #: plugin.py:620
msgid "requested factoids" msgid "requested factoids"
msgstr "" msgstr ""
#: plugin.py:622 #: plugin.py:621
msgid "Top %s: %L" msgid "Top %s: %L"
msgstr "" msgstr ""
#: plugin.py:624 #: plugin.py:623
msgid "No factoids have been requested from my database." msgid "No factoids have been requested from my database."
msgstr "" msgstr ""
#: plugin.py:628 #: plugin.py:627
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <author name>\n" "[<channel>] <author name>\n"
@ -196,15 +204,15 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:641 #: plugin.py:640
msgid "No factoids by %q found." msgid "No factoids by %q found."
msgstr "" msgstr ""
#: plugin.py:644 #: plugin.py:643
msgid "Author search for %q (%i found): %L" msgid "Author search for %q (%i found): %L"
msgstr "" msgstr ""
#: plugin.py:651 #: plugin.py:650
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <text>\n" "[<channel>] <text>\n"
@ -215,15 +223,15 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:659 #: plugin.py:658
msgid "No keys matching %q found." msgid "No keys matching %q found."
msgstr "" msgstr ""
#: plugin.py:666 #: plugin.py:665
msgid "Key search for %q (%i found): %L" msgid "Key search for %q (%i found): %L"
msgstr "" msgstr ""
#: plugin.py:673 #: plugin.py:672
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <text>\n" "[<channel>] <text>\n"
@ -234,15 +242,15 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:681 #: plugin.py:680
msgid "No values matching %q found." msgid "No values matching %q found."
msgstr "" msgstr ""
#: plugin.py:684 #: plugin.py:683
msgid "Value search for %q (%i found): %L" msgid "Value search for %q (%i found): %L"
msgstr "" msgstr ""
#: plugin.py:691 #: plugin.py:690
#, docstring #, docstring
msgid "" msgid ""
"[<channel>] <factoid key>\n" "[<channel>] <factoid key>\n"
@ -252,7 +260,7 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:704 #: plugin.py:703
#, docstring #, docstring
msgid "" msgid ""
"[<channel>]\n" "[<channel>]\n"
@ -263,7 +271,7 @@ msgid ""
" " " "
msgstr "" msgstr ""
#: plugin.py:712 #: plugin.py:711
msgid "No factoids in the database." msgid "No factoids in the database."
msgstr "" msgstr ""

View File

@ -591,9 +591,9 @@ class MoobotFactoids(callbacks.Plugin):
L = ['%s (%s)' % (plugins.getUserName(t[0]), int(t[1])) L = ['%s (%s)' % (plugins.getUserName(t[0]), int(t[1]))
for t in results] for t in results]
if L: if L:
author = 'author' author = _('author')
if len(L) != 1: if len(L) != 1:
author = 'authors' author = _('authors')
irc.reply(format(_('Most prolific %s: %L'), author, L)) irc.reply(format(_('Most prolific %s: %L'), author, L))
else: else:
irc.error(_('There are no factoids in my database.')) irc.error(_('There are no factoids in my database.'))

View File

@ -67,6 +67,14 @@ def get_plugin_dir(plugin_name):
return filename[0:-len(allowed_file)] return filename[0:-len(allowed_file)]
return return
def getLocalePath(name, localeName, extension):
if name != 'supybot':
directory = get_plugin_dir(name) + 'locale'
else:
import ansi # Any Supybot plugin could fit
directory = ansi.__file__[0:-len('ansi.pyc')] + 'locale'
return '%s/%s.%s' % (directory, localeName, extension)
i18nClasses = {} i18nClasses = {}
internationalizedCommands = {} internationalizedCommands = {}
@ -93,9 +101,11 @@ class PluginInternationalization:
elif localeName is None: elif localeName is None:
localeName = 'en' localeName = 'en'
self.currentLocaleName = localeName self.currentLocaleName = localeName
directory = get_plugin_dir(self.name) + 'locale'
try: try:
translationFile = open('%s/%s.po' % (directory, localeName), 'ru') translationFile = open(getLocalePath(self.name, localeName, 'po'),
'ru') # ru is the mode, not the beginning
# of 'russian' ;)
except IOError: # The translation is unavailable except IOError: # The translation is unavailable
self.translations = {} self.translations = {}
return return
@ -171,6 +181,20 @@ class PluginInternationalization:
except KeyError: except KeyError:
return untranslated % args return untranslated % args
def _getL10nCode(self):
return getLocalePath('supybot', self.currentLocaleName, 'py')
def getPluralizers(self, current_pluralize, current_depluralize):
# This should be used only by src/utils/str.py
try:
execfile(self._getL10nCode())
except IOError:
pass # Handled by the else v-
if locals().has_key('pluralize') and locals().has_key('depluralize'):
return (pluralize, depluralize)
else:
return (current_pluralize, current_depluralize)
def internationalizeDocstring(obj): def internationalizeDocstring(obj):
# FIXME: check if the plugin has an _ object # FIXME: check if the plugin has an _ object

View File

@ -42,6 +42,9 @@ import textwrap
from iter import all, any from iter import all, any
from structures import TwoWayDictionary from structures import TwoWayDictionary
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization()
curry = new.instancemethod curry = new.instancemethod
chars = string.maketrans('', '') chars = string.maketrans('', '')
@ -253,12 +256,12 @@ def matchCase(s1, s2):
L[i] = L[i].upper() L[i] = L[i].upper()
return ''.join(L) return ''.join(L)
consonants = 'bcdfghjklmnpqrstvwxz'
_pluralizeRegex = re.compile('[%s]y$' % consonants)
def pluralize(s): def pluralize(s):
"""Returns the plural of s. Put any exceptions to the general English """Returns the plural of s. Put any exceptions to the general English
rule of appending 's' in the plurals dictionary. rule of appending 's' in the plurals dictionary.
""" """
consonants = 'bcdfghjklmnpqrstvwxz'
_pluralizeRegex = re.compile('[%s]y$' % consonants)
lowered = s.lower() lowered = s.lower()
# Exception dictionary # Exception dictionary
if lowered in plurals: if lowered in plurals:
@ -275,9 +278,9 @@ def pluralize(s):
else: else:
return matchCase(s, s+'s') return matchCase(s, s+'s')
_depluralizeRegex = re.compile('[%s]ies' % consonants)
def depluralize(s): def depluralize(s):
"""Returns the singular of s.""" """Returns the singular of s."""
_depluralizeRegex = re.compile('[%s]ies' % consonants)
lowered = s.lower() lowered = s.lower()
if lowered in plurals: if lowered in plurals:
return matchCase(s, plurals[lowered]) return matchCase(s, plurals[lowered])
@ -291,6 +294,8 @@ def depluralize(s):
else: else:
return s # Don't know what to do. return s # Don't know what to do.
pluralize, depluralize = _.getPluralizers(pluralize, depluralize)
def nItems(n, item, between=None): def nItems(n, item, between=None):
"""Works like this: """Works like this: