Fixes in i18n

This commit is contained in:
Antonio de la Rosa 2018-01-12 05:14:54 +01:00
parent c65d47a5b4
commit 45cd953f8d
4 changed files with 27 additions and 4 deletions

View file

@ -52,9 +52,10 @@ class I18n:
return lang return lang
@staticmethod @staticmethod
def lang(module, symbol, text_default): def lang(module, symbol, text_default, lang=None):
lang=I18n.get_default_lang() if not lang:
lang=I18n.get_default_lang()
I18n.l[lang]=I18n.l.get(lang, {}) I18n.l[lang]=I18n.l.get(lang, {})
@ -81,3 +82,14 @@ class I18n:
def get_browser_lang(): def get_browser_lang():
return request.headers.get('Accept-Language') return request.headers.get('Accept-Language')
@staticmethod
def lang_json(module, symbol, text_default):
arr_final={}
for l in I18n.dict_i18n:
arr_final[l]=I18n.lang(module, symbol, text_default, l)
return json.dumps(arr_final)

View file

@ -9,7 +9,8 @@ tinymce.init({
height: 500, height: 500,
menubar: true, menubar: true,
plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern', plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern',
toolbar: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', toolbar: 'formatselect | fontsizeselect bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat',
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt 48pt 64pt 100pt 120pt",
content_css: '//www.tinymce.com/css/codepen.min.css', content_css: '//www.tinymce.com/css/codepen.min.css',
setup: function (editor) { setup: function (editor) {
editor.on('change', function () { editor.on('change', function () {

View file

@ -20,6 +20,7 @@ class I18nField(PhangoField):
self.name_form=I18nForm self.name_form=I18nForm
self.extra_parameters=[form] self.extra_parameters=[form]
self.show_formatted_value=True
def check_value(self, value): def check_value(self, value):

View file

@ -101,6 +101,10 @@ class PhangoField:
# Error by default # Error by default
self.error_default='Error: field required' self.error_default='Error: field required'
# Show this value formatted
self.show_formatted_value=False
# This method is used for describe the new field in a sql language format. # This method is used for describe the new field in a sql language format.
@ -749,7 +753,8 @@ class WebModel:
if self.show_formatted and row: if self.show_formatted and row:
for k, col in row.items(): for k, col in row.items():
row[k]=self.fields[k].show_formatted(col) if self.fields[k].show_formatted_value:
row[k]=self.fields[k].show_formatted(col)
results.append(row) results.append(row)
@ -786,6 +791,10 @@ class WebModel:
with self.select(fields_selected, raw_query) as cursor: with self.select(fields_selected, raw_query) as cursor:
for row in cursor: for row in cursor:
if self.show_formatted and row:
for k, col in row.items():
row[k]=self.fields[k].show_formatted(col)
results[row[self.name_field_id]]=row results[row[self.name_field_id]]=row