language changes
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.2.1 (2012-10-22 18:50:13) stable
|
||||
Version 2.2.1 (2012-10-22 22:14:35) stable
|
||||
|
||||
@@ -998,11 +998,11 @@ def design():
|
||||
statics.sort()
|
||||
|
||||
# Get all languages
|
||||
langpath = os.path.join(apath(app, r=request),'language')
|
||||
languages = dict([(lang, info) for lang, info
|
||||
in read_possible_languages(
|
||||
apath(app, r=request)).iteritems()
|
||||
in read_possible_languages(langpath).iteritems()
|
||||
if info[2] != 0]) # info[2] is langfile_mtime:
|
||||
# get only existed files
|
||||
# get only existed files
|
||||
|
||||
#Get crontab
|
||||
cronfolder = apath('%s/cron' % app, r=request)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" è un\'espressione opzionale come "campo1=\'nuovo valore\'". Non si può fare "update" o "delete" dei risultati di un JOIN ',
|
||||
'%(nrows)s records found': '%(nrows)s records found',
|
||||
'%d seconds ago': '%d seconds ago',
|
||||
'%m/%d/%Y': '%m/%d/%Y',
|
||||
'%s %%{row} deleted': '%s righe ("record") cancellate',
|
||||
'%s %%{row} updated': '%s righe ("record") modificate',
|
||||
'%s selected': '%s selezionato',
|
||||
|
||||
+2
-1
@@ -396,7 +396,8 @@ def build_environment(request, response, session, store_current=True):
|
||||
response.models_to_run = [r'^\w+\.py$', r'^%s/\w+\.py$' % request.controller,
|
||||
r'^%s/%s/\w+\.py$' % (request.controller, request.function)]
|
||||
|
||||
t = environment['T'] = translator(request)
|
||||
t = environment['T'] = translator(os.path.join(request.folder,'languages'),
|
||||
request.env.http_accept_langauge)
|
||||
c = environment['cache'] = Cache(request)
|
||||
|
||||
if store_current:
|
||||
|
||||
+11
-13
@@ -261,10 +261,9 @@ def read_possible_languages_aux(langdir):
|
||||
return langs
|
||||
|
||||
|
||||
def read_possible_languages(appdir):
|
||||
langdir = pjoin(appdir, 'languages')
|
||||
return getcfs('langs:' + langdir, langdir,
|
||||
lambda: read_possible_languages_aux(langdir))
|
||||
def read_possible_languages(langpath):
|
||||
return getcfs('langs:' + langpath, langpath,
|
||||
lambda: read_possible_languages_aux(langpath))
|
||||
|
||||
|
||||
def read_plural_dict_aux(filename):
|
||||
@@ -434,11 +433,9 @@ class translator(object):
|
||||
xx-yy.py -> xx.py -> xx-yy*.py -> xx*.py
|
||||
"""
|
||||
|
||||
def __init__(self, request):
|
||||
self.request = request
|
||||
self.folder = request.folder
|
||||
self.langpath = pjoin(self.folder, 'languages')
|
||||
self.http_accept_language = request.env.http_accept_language
|
||||
def __init__(self, langpath, http_accept_language):
|
||||
self.langpath = langpath
|
||||
self.http_accept_language = http_accept_language
|
||||
self.is_writable = not is_gae
|
||||
# filled in self.force():
|
||||
#------------------------
|
||||
@@ -493,7 +490,7 @@ class translator(object):
|
||||
construct_plural_form) # construct_plural_form() for current language
|
||||
}
|
||||
"""
|
||||
info = read_possible_languages(self.folder)
|
||||
info = read_possible_languages(self.langpath)
|
||||
if lang:
|
||||
info = info.get(lang)
|
||||
return info
|
||||
@@ -501,7 +498,7 @@ class translator(object):
|
||||
def get_possible_languages(self):
|
||||
""" get list of all possible languages for current applications """
|
||||
return list(set(self.current_languages +
|
||||
[lang for lang in read_possible_languages(self.folder).iterkeys()
|
||||
[lang for lang in read_possible_languages(self.langpath).iterkeys()
|
||||
if lang != 'default']))
|
||||
|
||||
def set_current_languages(self, *languages):
|
||||
@@ -581,7 +578,7 @@ class translator(object):
|
||||
default language will be selected if none
|
||||
of them matches possible_languages.
|
||||
"""
|
||||
pl_info = read_possible_languages(self.folder)
|
||||
pl_info = read_possible_languages(self.langpath)
|
||||
|
||||
def set_plural(language):
|
||||
"""
|
||||
@@ -670,7 +667,8 @@ class translator(object):
|
||||
try:
|
||||
otherT = self.otherTs[language]
|
||||
except KeyError:
|
||||
otherT = self.otherTs[language] = translator(self.request)
|
||||
otherT = self.otherTs[language] = translator(
|
||||
self.langpath, self.http_accept_language)
|
||||
otherT.force(language)
|
||||
return otherT(message, symbols, lazy=lazy)
|
||||
|
||||
|
||||
@@ -57,20 +57,18 @@ try:
|
||||
class TestTranslations(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.request = Storage()
|
||||
if os.path.isdir('gluon'):
|
||||
self.request.folder = 'applications/welcome'
|
||||
self.langpath = 'applications/welcome/languages'
|
||||
else:
|
||||
self.request.folder = os.path.realpath(
|
||||
'../../applications/welcome')
|
||||
self.request.env = Storage()
|
||||
self.request.env.http_accept_language = 'en'
|
||||
self.langpath = os.path.realpath(
|
||||
'../../applications/welcome/languages')
|
||||
self.http_accept_language = 'en'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_plain(self):
|
||||
T = languages.translator(self.request)
|
||||
T = languages.translator(self.langpath, self.http_accept_language)
|
||||
self.assertEqual(str(T('Hello World')),
|
||||
'Hello World')
|
||||
self.assertEqual(str(T('Hello World## comment')),
|
||||
|
||||
Reference in New Issue
Block a user