Merge branch 'l10n-fr' into testing

This commit is contained in:
Valentin Lorentz 2010-10-31 18:37:15 +01:00
commit 51edf7325c
5 changed files with 1240 additions and 176 deletions

1043
locale/fr.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -852,8 +852,11 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
allowedLength = conf.get(conf.supybot.reply.mores.length,
target)
if not allowedLength: # 0 indicates this.
allowedLength = 450 - len(self.irc.prefix)
allowedLength = 470 - len(self.irc.prefix)
allowedLength -= len(msg.nick)
# The '(XX more messages)' may have not the same
# length in the current locale
allowedLength -= len(_('(XX more messages)'))
maximumMores = conf.get(conf.supybot.reply.mores.maximum,
target)
maximumLength = allowedLength * maximumMores
@ -866,7 +869,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
# In case we're truncating, we add 20 to allowedLength,
# because our allowedLength is shortened for the
# "(XX more messages)" trailer.
s = s[:allowedLength+20]
s = s[:allowedLength+len(_('(XX more messages)'))]
# There's no need for action=self.action here because
# action implies noLengthCheck, which has already been
# handled. Let's stick an assert in here just in case.

View File

@ -611,9 +611,9 @@ registerChannelValue(supybot.commands.nested, 'pipeSyntax',
example: 'bot: foo | bar'.""")))
registerGroup(supybot.commands, 'defaultPlugins',
orderAlphabetically=True, help="""Determines what commands have default
orderAlphabetically=True, help=_("""Determines what commands have default
plugins set, and which plugins are set to be the default for each of those
commands.""")
commands."""))
registerGlobalValue(supybot.commands.defaultPlugins, 'importantPlugins',
registry.SpaceSeparatedSetOfStrings(
['Admin', 'Channel', 'Config', 'Misc', 'Owner', 'Plugin', 'User'],

View File

@ -57,7 +57,16 @@ def import_conf():
i18nClasses[key].loadLocale()
def get_plugin_dir(plugin_name):
filename = sys.modules[plugin_name].__file__
filename = None
try:
filename = sys.modules[plugin_name].__file__
except KeyError: # This is odd
pass
if filename == None:
try:
filename = sys.modules['supybot.plugins.' + plugin_name].__file__
except KeyError: # This is odder
return
if filename.endswith(".pyc"):
filename = filename[0:-1]
@ -69,7 +78,10 @@ def get_plugin_dir(plugin_name):
def getLocalePath(name, localeName, extension):
if name != 'supybot':
directory = get_plugin_dir(name) + 'locale'
try:
directory = get_plugin_dir(name) + 'locale'
except TypeError: # get_plugin_dir returned None
return ''
else:
import ansi # Any Supybot plugin could fit
directory = ansi.__file__[0:-len('ansi.pyc')] + 'locale'
@ -90,14 +102,11 @@ def reloadLocals():
i18nSupybot = None
def PluginInternationalization(name='supybot'):
# This is a proxy, that prevent Supybot against having more than one
# internationalizer
global i18nSupybot
if name != 'supybot':
# This is a proxy that prevents having several objects for the same plugin
if i18nClasses.has_key(name):
return i18nClasses[name]
else:
return _PluginInternationalization(name)
elif i18nSupybot == None:
i18nSupybot = _PluginInternationalization('supybot')
return i18nSupybot
class _PluginInternationalization:
"""Internationalization managment for a plugin."""
@ -127,8 +136,6 @@ class _PluginInternationalization:
self._parse(translationFile)
except IOError: # The translation is unavailable
self.translations = {}
return
def _parse(self, translationFile):
"""A .po files parser.
@ -268,4 +275,4 @@ def internationalizeDocstring(obj):
internationalizedCommands.update({hash(obj): obj})
obj.__doc__=sys.modules[obj.__module__]._.__call__(obj.__doc__)
# We use _.__call__() instead of _() because of a pygettext warning.
return obj
return obj