Fixes in default lang
This commit is contained in:
parent
9cd3ada7b4
commit
3596838864
6 changed files with 35 additions and 21 deletions
|
|
@ -5,6 +5,8 @@ from paramecio2.libraries.db.coreforms import PasswordForm
|
|||
from paramecio2.libraries.i18n import I18n
|
||||
from flask import session, request, abort
|
||||
from paramecio2.libraries.keyutils import create_key_encrypt
|
||||
from paramecio2.libraries.i18n import I18n, PGetText
|
||||
|
||||
|
||||
# Need unittest
|
||||
"""Functions and classes for process forms"""
|
||||
|
|
@ -178,7 +180,7 @@ def set_extra_forms_user(user_admin):
|
|||
|
||||
user_admin.forms['repeat_password'].required=True
|
||||
|
||||
user_admin.forms['repeat_password'].label=I18n.lang('common', 'repeat_password', 'Repeat Password')
|
||||
user_admin.forms['repeat_password'].label=_('Repeat Password')
|
||||
|
||||
def csrf_token(token_id='csrf_token'):
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ from flask import request, redirect, flash
|
|||
from paramecio2.libraries.urls import add_get_parameters
|
||||
#from paramecio.citoplasma.mtemplates import set_flash_message
|
||||
from paramecio2.libraries.formsutils import show_form
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
from paramecio2.libraries.i18n import I18n, PGetText
|
||||
from collections import OrderedDict
|
||||
|
||||
pgettext=PGetText(__file__)
|
||||
_=pgettext.gettext
|
||||
|
||||
class GenerateAdminClass:
|
||||
"""Class for insert, update and list items of a model
|
||||
"""
|
||||
|
|
@ -76,7 +79,7 @@ class GenerateAdminClass:
|
|||
|
||||
self.post_update=None
|
||||
|
||||
self.text_home=I18n.lang('common', 'home', 'Home')
|
||||
self.text_home=_('Home')
|
||||
|
||||
def show(self):
|
||||
""" Method for show the admin model
|
||||
|
|
@ -106,13 +109,13 @@ class GenerateAdminClass:
|
|||
|
||||
post=None
|
||||
|
||||
title_edit=I18n.lang('common', 'add_new_item', 'Add new item')
|
||||
title_edit=_('Add new item')
|
||||
|
||||
pass_value=False
|
||||
|
||||
if item_id!='0':
|
||||
post=self.model.select_a_row(item_id, [], True)
|
||||
title_edit=I18n.lang('common', 'edit_new_item', 'Edit item')
|
||||
title_edit=_('Edit item')
|
||||
pass_value=True
|
||||
|
||||
if post==None or post==False:
|
||||
|
|
@ -149,12 +152,12 @@ class GenerateAdminClass:
|
|||
|
||||
item_id='0'
|
||||
|
||||
title_edit=I18n.lang('common', 'add_new_item', 'Add new item')
|
||||
title_edit=_('Add new item')
|
||||
|
||||
|
||||
if item_id!='0':
|
||||
insert_row=self.model.update
|
||||
title_edit=I18n.lang('common', 'edit_new_item', 'Edit item')
|
||||
title_edit=_('Edit item')
|
||||
self.model.conditions=['WHERE `'+self.model.name+'`.`'+self.model.name_field_id+'`=%s', [item_id]]
|
||||
|
||||
post=dict(request.form)
|
||||
|
|
@ -162,7 +165,7 @@ class GenerateAdminClass:
|
|||
if pre_update_ret:
|
||||
|
||||
if insert_row(post):
|
||||
flash(I18n.lang('common', 'task_successful', 'Task successful'))
|
||||
flash(_('Task successful'))
|
||||
|
||||
if self.post_update:
|
||||
if item_id=='0':
|
||||
|
|
@ -203,7 +206,7 @@ class GenerateAdminClass:
|
|||
if item_id!='0':
|
||||
self.model.conditions=['WHERE `'+self.model.name+'`.`'+self.model.name_field_id+'`=%s', [item_id]]
|
||||
self.model.delete()
|
||||
flash(I18n.lang('common', 'task_successful', 'Task successful'))
|
||||
flash(_('Task successful'))
|
||||
return redirect(self.url_redirect)
|
||||
|
||||
else:
|
||||
|
|
@ -282,7 +285,7 @@ class GenerateConfigClass:
|
|||
|
||||
self.post_update=None
|
||||
|
||||
self.text_home=I18n.lang('common', 'home', 'Home')
|
||||
self.text_home=_('Home')
|
||||
|
||||
def show(self):
|
||||
|
||||
|
|
@ -298,7 +301,7 @@ class GenerateConfigClass:
|
|||
|
||||
self.model.create_forms()
|
||||
|
||||
title_edit=I18n.lang('common', 'edit', 'Edit')+' '+self.title_name
|
||||
title_edit=_('Edit')+' '+self.title_name
|
||||
|
||||
edit_forms=OrderedDict()
|
||||
|
||||
|
|
@ -323,7 +326,7 @@ class GenerateConfigClass:
|
|||
post=dict(request.form)
|
||||
|
||||
if insert_model(post):
|
||||
set_flash_message(I18n.lang('common', 'task_successful', 'Task successful'))
|
||||
set_flash_message(_('Task successful'))
|
||||
self.model.yes_reset_conditions=True
|
||||
|
||||
if self.post_update:
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class PGetText:
|
|||
|
||||
PGetText.l[module_name][i]=gettext.translation(module_name, module_dir+'/languages/', languages=[i], fallback=True)
|
||||
PGetText.l[module_name][i].install()
|
||||
|
||||
|
||||
self.module=module_name
|
||||
|
||||
def gettext(self, text):
|
||||
|
|
@ -170,3 +170,4 @@ class I18n:
|
|||
|
||||
return json.dumps(arr_final)
|
||||
|
||||
common_pgettext=PGetText(__file__)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
from paramecio2.libraries.pages import Pages
|
||||
from paramecio2.libraries.urls import add_get_parameters
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
from paramecio2.libraries.i18n import I18n, PGetText
|
||||
#from flask import request, session
|
||||
from paramecio2.libraries.get_data import get_query_args
|
||||
import sys
|
||||
import re
|
||||
|
||||
pgettext=PGetText(__file__)
|
||||
_=pgettext.gettext
|
||||
|
||||
class SimpleList:
|
||||
"""Class for create item list from a model table
|
||||
"""
|
||||
|
|
@ -107,7 +110,7 @@ class SimpleList:
|
|||
|
||||
#self.yes_options=True
|
||||
|
||||
self.arr_extra_fields=[I18n.lang('common', 'options', 'Options')]
|
||||
self.arr_extra_fields=[_('Options')]
|
||||
|
||||
self.arr_extra_options=[SimpleList.standard_options]
|
||||
|
||||
|
|
@ -216,8 +219,8 @@ class SimpleList:
|
|||
options (list): Return a list of basic options for items row
|
||||
"""
|
||||
options=[]
|
||||
options.append('<a href="'+add_get_parameters(url, op_admin=1, id=id)+'">'+I18n.lang('common', 'edit', 'Edit')+'</a>')
|
||||
options.append('<a href="'+add_get_parameters(url, op_admin=3, id=id)+'">'+I18n.lang('common', 'delete', 'Delete')+'</a>')
|
||||
options.append('<a href="'+add_get_parameters(url, op_admin=1, id=id)+'">'+_('Edit')+'</a>')
|
||||
options.append('<a href="'+add_get_parameters(url, op_admin=3, id=id)+'">'+_('Delete')+'</a>')
|
||||
return options
|
||||
|
||||
def show(self):
|
||||
|
|
@ -286,7 +289,7 @@ class AjaxList(SimpleList):
|
|||
"""Class for make a list from a table based in Ajax
|
||||
"""
|
||||
|
||||
# Fields example: [[I18n.lang('cuchulu', 'hostname', 'Hostname'), True], ['IP', True], [I18n.lang('cuchulu', 'options', 'Options'), False]]
|
||||
# Fields example: [['Hostname', True], ['IP', True], ['Options', False]]
|
||||
|
||||
# arr_order_fields=['server.hostname', 'server.ip']
|
||||
|
||||
|
|
@ -389,7 +392,7 @@ class AjaxList(SimpleList):
|
|||
|
||||
pages=Pages()
|
||||
|
||||
html_pages=I18n.lang('cuchulu', 'pages', 'Pages')+': '+pages.show( begin_page, total_elements, limit, '#' ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='')
|
||||
html_pages=_('Pages')+': '+pages.show( begin_page, total_elements, limit, '#' ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='')
|
||||
|
||||
with self.db.query(str_query, params) as cursor:
|
||||
for row in cursor:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<!--<h1>${admin.title}</h1>-->
|
||||
<p><a href="${add_get_parameters(admin.url, op_admin='1')}">${lang('common', 'add_item', 'Add new item')}</a></p>
|
||||
<p><a href="${add_get_parameters(admin.url, op_admin='1')}">${_('Add new item')}</a></p>
|
||||
${admin.list.show()|n}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@
|
|||
from settings import config
|
||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||
from paramecio2.modules.welcome import welcome_app
|
||||
from paramecio2.libraries.i18n import PGetText
|
||||
|
||||
pgettext=PGetText(__file__)
|
||||
|
||||
_=pgettext.gettext
|
||||
|
||||
env=env_theme(__file__)
|
||||
|
||||
|
|
@ -10,7 +15,7 @@ t=PTemplate(env)
|
|||
@welcome_app.route('/welcome')
|
||||
def home():
|
||||
|
||||
return t.load_template('welcome.phtml', title="Welcome", content='Welcome to the real world')
|
||||
return t.load_template('welcome.phtml', title=_("Welcome"), content=_('Welcome to the real world'))
|
||||
|
||||
#return render_template('welcome.html', title="Welcome")
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue