fixed issue 1196:add language subfolders, thanks jamarcer
This commit is contained in:
@@ -81,6 +81,7 @@ app:
|
|||||||
cp -r applications/examples ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
|
cp -r applications/examples ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
|
||||||
cp applications/__init__.py ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
|
cp applications/__init__.py ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
|
||||||
cd ../web2py_osx; zip -r web2py_osx.zip web2py
|
cd ../web2py_osx; zip -r web2py_osx.zip web2py
|
||||||
|
|
||||||
mv ../web2py_osx/web2py_osx.zip .
|
mv ../web2py_osx/web2py_osx.zip .
|
||||||
win:
|
win:
|
||||||
python2.7 -c 'import compileall; compileall.compile_dir("gluon/")'
|
python2.7 -c 'import compileall; compileall.compile_dir("gluon/")'
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Version 2.6.4-stable+timestamp.2013.09.22.10.09.42
|
Version 2.6.4-stable+timestamp.2013.09.23.14.53.34
|
||||||
|
|||||||
+4
-5
File diff suppressed because one or more lines are too long
+4
-5
File diff suppressed because one or more lines are too long
+4
-5
File diff suppressed because one or more lines are too long
+35
-15
@@ -474,6 +474,8 @@ class translator(object):
|
|||||||
self.otherTs = {}
|
self.otherTs = {}
|
||||||
self.filter = markmin
|
self.filter = markmin
|
||||||
self.ftag = 'markmin'
|
self.ftag = 'markmin'
|
||||||
|
|
||||||
|
self.ns = None
|
||||||
|
|
||||||
def get_possible_languages_info(self, lang=None):
|
def get_possible_languages_info(self, lang=None):
|
||||||
"""
|
"""
|
||||||
@@ -665,26 +667,46 @@ class translator(object):
|
|||||||
set_plural(self.accepted_language)
|
set_plural(self.accepted_language)
|
||||||
return languages
|
return languages
|
||||||
|
|
||||||
def __call__(self, message, symbols={}, language=None, lazy=None):
|
def __call__(self, message, symbols={}, language=None, lazy=None, ns=None):
|
||||||
"""
|
"""
|
||||||
get cached translated plain text message with inserted parameters(symbols)
|
get cached translated plain text message with inserted parameters(symbols)
|
||||||
if lazy==True lazyT object is returned
|
if lazy==True lazyT object is returned
|
||||||
"""
|
"""
|
||||||
if lazy is None:
|
if lazy is None:
|
||||||
lazy = self.lazy
|
lazy = self.lazy
|
||||||
if not language:
|
if not language and not ns:
|
||||||
if lazy:
|
if lazy:
|
||||||
return lazyT(message, symbols, self)
|
return lazyT(message, symbols, self)
|
||||||
else:
|
else:
|
||||||
return self.translate(message, symbols)
|
return self.translate(message, symbols)
|
||||||
else:
|
else:
|
||||||
try:
|
if ns:
|
||||||
otherT = self.otherTs[language]
|
if ns != self.ns:
|
||||||
except KeyError:
|
self.langpath = os.path.join(self.langpath, ns)
|
||||||
otherT = self.otherTs[language] = translator(
|
if self.ns is None:
|
||||||
self.langpath, self.http_accept_language)
|
self.ns = ns
|
||||||
otherT.force(language)
|
otherT = self.__get_otherT__(language, ns)
|
||||||
return otherT(message, symbols, lazy=lazy)
|
return otherT(message, symbols, lazy=lazy)
|
||||||
|
|
||||||
|
def __get_otherT__(self, language=None, namespace=None):
|
||||||
|
if not language and not namespace:
|
||||||
|
raise Exception('Incorrect parameters')
|
||||||
|
|
||||||
|
if namespace:
|
||||||
|
if language:
|
||||||
|
index = '%s/%s' % (namespace, language)
|
||||||
|
else:
|
||||||
|
index = namespace
|
||||||
|
else:
|
||||||
|
index = language
|
||||||
|
try:
|
||||||
|
otherT = self.otherTs[index]
|
||||||
|
except KeyError:
|
||||||
|
otherT = self.otherTs[index] = translator(self.langpath, \
|
||||||
|
self.http_accept_language)
|
||||||
|
if language:
|
||||||
|
otherT.force(language)
|
||||||
|
return otherT
|
||||||
|
|
||||||
def apply_filter(self, message, symbols={}, filter=None, ftag=None):
|
def apply_filter(self, message, symbols={}, filter=None, ftag=None):
|
||||||
def get_tr(message, prefix, filter):
|
def get_tr(message, prefix, filter):
|
||||||
@@ -714,24 +736,22 @@ class translator(object):
|
|||||||
return XML(message.translate(ttab_out))
|
return XML(message.translate(ttab_out))
|
||||||
|
|
||||||
def M(self, message, symbols={}, language=None,
|
def M(self, message, symbols={}, language=None,
|
||||||
lazy=None, filter=None, ftag=None):
|
lazy=None, filter=None, ftag=None, ns=None):
|
||||||
"""
|
"""
|
||||||
get cached translated markmin-message with inserted parametes
|
get cached translated markmin-message with inserted parametes
|
||||||
if lazy==True lazyT object is returned
|
if lazy==True lazyT object is returned
|
||||||
"""
|
"""
|
||||||
if lazy is None:
|
if lazy is None:
|
||||||
lazy = self.lazy
|
lazy = self.lazy
|
||||||
if not language:
|
if not language and not ns:
|
||||||
if lazy:
|
if lazy:
|
||||||
return lazyT(message, symbols, self, filter, ftag, True)
|
return lazyT(message, symbols, self, filter, ftag, True)
|
||||||
else:
|
else:
|
||||||
return self.apply_filter(message, symbols, filter, ftag)
|
return self.apply_filter(message, symbols, filter, ftag)
|
||||||
else:
|
else:
|
||||||
try:
|
if ns:
|
||||||
otherT = self.otherTs[language]
|
self.langpath = os.path.join(self.langpath, ns)
|
||||||
except KeyError:
|
otherT = self.__get_otherT__(language, ns)
|
||||||
otherT = self.otherTs[language] = translator(self.request)
|
|
||||||
otherT.force(language)
|
|
||||||
return otherT.M(message, symbols, lazy=lazy)
|
return otherT.M(message, symbols, lazy=lazy)
|
||||||
|
|
||||||
def get_t(self, message, prefix=''):
|
def get_t(self, message, prefix=''):
|
||||||
|
|||||||
Reference in New Issue
Block a user