T.is_writable, thanks Fran
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.1.1 (2012-10-16 11:47:13) dev
|
Version 2.1.1 (2012-10-17 09:13:38) dev
|
||||||
|
|||||||
+5
-6
@@ -35,8 +35,7 @@ pjoin = os.path.join
|
|||||||
pexists = os.path.exists
|
pexists = os.path.exists
|
||||||
pdirname = os.path.dirname
|
pdirname = os.path.dirname
|
||||||
isdir = os.path.isdir
|
isdir = os.path.isdir
|
||||||
is_writable = not (settings.global_settings.web2py_runtime_gae or
|
is_gae = settings.global_settings.web2py_runtime_gae
|
||||||
settings.global_settings.languages_readonly)
|
|
||||||
|
|
||||||
DEFAULT_LANGUAGE = 'en'
|
DEFAULT_LANGUAGE = 'en'
|
||||||
DEFAULT_LANGUAGE_NAME = 'English'
|
DEFAULT_LANGUAGE_NAME = 'English'
|
||||||
@@ -275,7 +274,7 @@ def write_plural_dict(filename, contents):
|
|||||||
fp.write('%s: %s,\n' % (repr(Utf8(key)), forms))
|
fp.write('%s: %s,\n' % (repr(Utf8(key)), forms))
|
||||||
fp.write('}\n')
|
fp.write('}\n')
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
if is_writable:
|
if not is_gae:
|
||||||
logging.warning('Unable to write to file %s' % filename)
|
logging.warning('Unable to write to file %s' % filename)
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
@@ -417,7 +416,7 @@ class translator(object):
|
|||||||
self.folder = request.folder
|
self.folder = request.folder
|
||||||
self.langpath = pjoin(self.folder, 'languages')
|
self.langpath = pjoin(self.folder, 'languages')
|
||||||
self.http_accept_language = request.env.http_accept_language
|
self.http_accept_language = request.env.http_accept_language
|
||||||
self.is_writable = is_writable
|
self.is_writable = not is_gae
|
||||||
# filled in self.force():
|
# filled in self.force():
|
||||||
#------------------------
|
#------------------------
|
||||||
# self.cache
|
# self.cache
|
||||||
@@ -539,7 +538,7 @@ class translator(object):
|
|||||||
form = self.construct_plural_form(word, id)
|
form = self.construct_plural_form(word, id)
|
||||||
forms[id-1] = form
|
forms[id-1] = form
|
||||||
self.plural_dict[word] = forms
|
self.plural_dict[word] = forms
|
||||||
if self.plural_file and self.is_writable:
|
if self.is_writable and self.plural_file:
|
||||||
write_plural_dict(self.plural_file,
|
write_plural_dict(self.plural_file,
|
||||||
self.plural_dict)
|
self.plural_dict)
|
||||||
return form
|
return form
|
||||||
@@ -725,7 +724,7 @@ class translator(object):
|
|||||||
# guess translation same as original
|
# guess translation same as original
|
||||||
self.t[key] = mt = self.default_t.get(key, message)
|
self.t[key] = mt = self.default_t.get(key, message)
|
||||||
# update language file for latter translation
|
# update language file for latter translation
|
||||||
if self.language_file != self.default_language_file and self.is_writable:
|
if self.is_writable and self.language_file != self.default_language_file:
|
||||||
write_dict(self.language_file, self.t)
|
write_dict(self.language_file, self.t)
|
||||||
return regex_backslash.sub(
|
return regex_backslash.sub(
|
||||||
lambda m: m.group(1).translate(ttab_in), mt)
|
lambda m: m.group(1).translate(ttab_in), mt)
|
||||||
|
|||||||
Reference in New Issue
Block a user