Merge pull request #2025 from leonelcamara/patch-20
Python 3 compatibility
This commit is contained in:
+5
-5
@@ -311,7 +311,7 @@ def write_plural_dict(filename, contents):
|
||||
try:
|
||||
fp = LockedFile(filename, 'w')
|
||||
fp.write('#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n{\n# "singular form (0)": ["first plural form (1)", "second plural form (2)", ...],\n')
|
||||
for key in sorted(contents, sort_function):
|
||||
for key in sorted(contents, key=sort_function):
|
||||
forms = '[' + ','.join([repr(Utf8(form))
|
||||
for form in contents[key]]) + ']'
|
||||
fp.write('%s: %s,\n' % (repr(Utf8(key)), forms))
|
||||
@@ -325,8 +325,8 @@ def write_plural_dict(filename, contents):
|
||||
fp.close()
|
||||
|
||||
|
||||
def sort_function(x, y):
|
||||
return cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())
|
||||
def sort_function(x):
|
||||
return unicode(x, 'utf-8').lower()
|
||||
|
||||
|
||||
def write_dict(filename, contents):
|
||||
@@ -936,8 +936,8 @@ class translator(object):
|
||||
word = w[1:]
|
||||
fun = cap_fun
|
||||
if i is not None:
|
||||
return fun(self.plural(word, symbols[int(i)]))
|
||||
return fun(word)
|
||||
return to_native(fun(self.plural(word, symbols[int(i)])))
|
||||
return to_native(fun(word))
|
||||
|
||||
def sub_dict(m):
|
||||
""" word(key or num)
|
||||
|
||||
Reference in New Issue
Block a user