diff --git a/paramecio/libraries/adminutils.py b/paramecio/libraries/adminutils.py index 86925c2..7698755 100644 --- a/paramecio/libraries/adminutils.py +++ b/paramecio/libraries/adminutils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from collections import OrderedDict -from paramecio.libraries.sessionplugin import get_session +from paramecio.libraries.sessions import get_session from paramecio.libraries.urls import make_url from paramecio.libraries.i18n import I18n from paramecio.libraries.httputils import GetPostFiles diff --git a/paramecio/libraries/check_i18n.py b/paramecio/libraries/check_i18n.py index 22ba1d8..0f64e66 100644 --- a/paramecio/libraries/check_i18n.py +++ b/paramecio/libraries/check_i18n.py @@ -42,14 +42,11 @@ def start(): path_save=args.module+'/i18n' - if args.module.endswith('/'): - args.module=args.module[:-1] - module_base=os.path.basename(args.module) - lang_p=re.compile(r"I18n\.lang\('({}?)',\s+'(.*?)',\s+'(.*?)'\)".format(module_base)) + lang_p=re.compile(r"I18n\.lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)") #lang_t=re.compile("\${lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)\}") - lang_t=re.compile(r"lang\('({}?)',\s+'(.*?)',\s+'(.*?)'\)".format(module_base)) + lang_t=re.compile(r"lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)") lang_s=re.compile(r"slang\('(.*?)',\s+'(.*?)'\)") diff --git a/paramecio/libraries/generate_admin_class.py b/paramecio/libraries/generate_admin_class.py index 8c67357..ec2e8da 100644 --- a/paramecio/libraries/generate_admin_class.py +++ b/paramecio/libraries/generate_admin_class.py @@ -3,14 +3,10 @@ from bottle import request from paramecio.libraries.urls import add_get_parameters, redirect from paramecio.libraries.mtemplates import set_flash_message from paramecio.libraries.db.formsutils import show_form -from paramecio.libraries.i18n import I18n, PGetText +from paramecio.libraries.i18n import I18n from paramecio.libraries.httputils import GetPostFiles from collections import OrderedDict -gtext=PGetText(__file__) - -_=gtext.gettext - class GenerateAdminClass: def __init__(self, model, url, t): @@ -57,7 +53,7 @@ class GenerateAdminClass: self.post_update=None - self.text_home=_('Home') + self.text_home=I18n.lang('common', 'home', 'Home') def show(self): @@ -84,13 +80,13 @@ class GenerateAdminClass: post=None - title_edit=_('Add new item') + title_edit=I18n.lang('common', 'add_new_item', 'Add new item') pass_value=False if getpostfiles.get['id']!='0': post=self.model.select_a_row(getpostfiles.get['id'], [], True) - title_edit=_('Edit item') + title_edit=I18n.lang('common', 'edit_new_item', 'Edit item') pass_value=True if post==None or post==False: @@ -124,19 +120,19 @@ class GenerateAdminClass: getpostfiles.get['id']='0' - title_edit=_('Add new item') + title_edit=I18n.lang('common', 'add_new_item', 'Add new item') if getpostfiles.get['id']!='0': insert_row=self.model.update - title_edit=_('Edit item') + title_edit=I18n.lang('common', 'edit_new_item', 'Edit item') self.model.conditions=['WHERE `'+self.model.name+'`.`'+self.model.name_field_id+'`=%s', [getpostfiles.get['id']]] if self.pre_update: getpostfiles.post=self.pre_update(self, getpostfiles.post) if insert_row(getpostfiles.post): - set_flash_message(_('Task successful')) + set_flash_message(I18n.lang('common', 'task_successful', 'Task successful')) if self.post_update: if getpostfiles.get['id']=='0': @@ -162,7 +158,7 @@ class GenerateAdminClass: if getpostfiles.get['id']!='0': self.model.conditions=['WHERE `'+self.model.name+'`.`'+self.model.name_field_id+'`=%s', [getpostfiles.get['id']]] self.model.delete() - set_flash_message(_('Task successful')) + set_flash_message(I18n.lang('common', 'task_successful', 'Task successful')) redirect(self.url_redirect) else: @@ -222,7 +218,7 @@ class GenerateConfigClass: self.post_update=None - self.text_home=_('Home') + self.text_home=I18n.lang('common', 'home', 'Home') def show(self): @@ -236,7 +232,7 @@ class GenerateConfigClass: self.model.create_forms() - title_edit=_('Edit')+' '+self.title_name + title_edit=I18n.lang('common', 'edit', 'Edit')+' '+self.title_name edit_forms=OrderedDict() @@ -261,7 +257,7 @@ class GenerateConfigClass: insert_model=self.model.update if insert_model(getpostfiles.post): - set_flash_message(_('Task successful')) + set_flash_message(I18n.lang('common', 'task_successful', 'Task successful')) self.model.yes_reset_conditions=True if self.post_update: diff --git a/paramecio/libraries/js.py b/paramecio/libraries/js.py index e7eaec0..230ef17 100644 --- a/paramecio/libraries/js.py +++ b/paramecio/libraries/js.py @@ -1,4 +1,4 @@ -from paramecio.libraries.sessionplugin import get_session +from paramecio.libraries.sessions import get_session from paramecio.libraries.i18n import I18n from settings import config diff --git a/paramecio/libraries/lists.py b/paramecio/libraries/lists.py index 25ad245..93cf2aa 100644 --- a/paramecio/libraries/lists.py +++ b/paramecio/libraries/lists.py @@ -3,17 +3,13 @@ from paramecio.libraries.pages import Pages from paramecio.libraries.urls import add_get_parameters from paramecio.libraries.sessions import get_session -from paramecio.libraries.i18n import I18n, PGetText +from paramecio.libraries.i18n import I18n from paramecio.libraries.httputils import GetPostFiles from bottle import request import sys import re from paramecio.libraries.pages import Pages -gtext=PGetText(__file__) - -_=gtext.gettext - class SimpleList: def __init__(self, model, url, t): @@ -80,7 +76,7 @@ class SimpleList: #self.yes_options=True - self.arr_extra_fields=[_('Options')] + self.arr_extra_fields=[I18n.lang('common', 'options', 'Options')] self.arr_extra_options=[SimpleList.standard_options] @@ -171,8 +167,8 @@ class SimpleList: @staticmethod def standard_options(url, id, arr_row): options=[] - options.append(''+_('Edit')+'') - options.append(''+_('Delete')+'') + options.append(''+I18n.lang('common', 'edit', 'Edit')+'') + options.append(''+I18n.lang('common', 'delete', 'Delete')+'') return options def show(self): @@ -314,7 +310,7 @@ class AjaxList(SimpleList): pages=Pages() - html_pages=_('Pages')+': '+pages.show( begin_page, total_elements, limit, '#' ,initial_num_pages=self.initial_num_pages, variable='begin_page', label='', func_jscript='') + 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='') with self.db.query(str_query, params) as cursor: for row in cursor: diff --git a/paramecio/libraries/mtemplates.py b/paramecio/libraries/mtemplates.py index 98e2040..fc054ae 100644 --- a/paramecio/libraries/mtemplates.py +++ b/paramecio/libraries/mtemplates.py @@ -33,10 +33,6 @@ from os import path from collections import OrderedDict from paramecio.wsgiapp import app -gtext=PGetText(__file__) - -_=gtext.gettext - # Preparing envs for views of modules, and views of def env_theme(module, cache_enabled=True, cache_impl='', cache_args={}, module_directory="./tmp/modules"): @@ -462,7 +458,7 @@ def set_flash_message(message): s['flash']=message - s.save() + #s.save() def qf(text): diff --git a/paramecio/libraries/pages.py b/paramecio/libraries/pages.py index e72def0..33a68a6 100644 --- a/paramecio/libraries/pages.py +++ b/paramecio/libraries/pages.py @@ -2,11 +2,7 @@ from math import ceil, floor from paramecio.libraries.urls import add_get_parameters -from paramecio.libraries.i18n import I18n, PGetText - -gtext=PGetText(__file__) - -_=gtext.gettext +from paramecio.libraries.i18n import I18n class Pages: @@ -68,7 +64,7 @@ class Pages: middle_link=add_get_parameters(link, **{variable: str(x+num_elements)} ); last_link=add_get_parameters(link, **{variable: str( ( ( total_page*num_elements ) - num_elements) ) } ) - pages += ">> "+_('Last')+"" + pages += ">> "+I18n.lang('common', 'last', 'Last')+"" return pages diff --git a/paramecio/libraries/slugify.py b/paramecio/libraries/slugify.py index 433758c..e6143f7 100644 --- a/paramecio/libraries/slugify.py +++ b/paramecio/libraries/slugify.py @@ -1,30 +1,60 @@ -""" -Paramecio2fm is a series of wrappers for Flask, mako and others and construct a simple headless cms. +#!/usr/bin/python -Copyright (C) 2023 Antonio de la Rosa Caballero +#A very simple version of strtr of php. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +def strtr(str_in, pat_str, rep_str): + + ret_str='' + + arr_dict={} + + if(len(pat_str)!=len(rep_str)): + raise NameError('Ups, pat_str len != rep_str len') + + #Create dictionary + + for (i, l) in enumerate(pat_str): + arr_dict[l]=rep_str[i] + + #Make a for to the str_in and substr. + + for le in str_in: + + if le in arr_dict: + + ret_str+=arr_dict[le] + + else: + ret_str+=le + + return (ret_str) -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. +def slugify(str_in, respect_upper=False, replace_space='-', replace_dot=False, replace_barr=False): + + str_out='' + + from_str='àáâãäåæçèéêëìíîïðòóôõöøùúûýþÿŕñÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÒÓÔÕÖØÙÚÛÝỲŸÞŔÑ¿?!¡()"|#*%,;+&$ºª<>`çÇ{}@~=^:´[]\'' + to_str= 'aaaaaaaceeeeiiiidoooooouuuybyrnAAAAAACEEEEIIIIDOOOOOOUUUYYYBRN----------------------------------' + + if replace_dot==True: + + from_str+='.' + from_to+='-' -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -""" + + if replace_barr==True: + + from_str+="/" + to_str+="-" + + str_out=str_in.strip() + + str_out=strtr(str_out, from_str, to_str) -from slugify import slugify as slugify_func - -def slugify(slug, *args, **wargs): - """Simple wrapper for slugify module https://github.com/un33k/python-slugify - - Args: - slug (str): The string to be slugified - - """ - - return slugify_func(slug, *args, **wargs) + str_out=str_out.replace(" ", replace_space) + + if respect_upper==False: + str_out=str_out.lower() + + return str_out + diff --git a/paramecio/modules/admin2/app.py b/paramecio/modules/admin2/app.py index 4e625e0..0c4a5b2 100644 --- a/paramecio/modules/admin2/app.py +++ b/paramecio/modules/admin2/app.py @@ -1,6 +1,6 @@ #from paramecio import wsgi_app -from paramecio.libraries.i18n import I18n, PGetText +from paramecio.libraries.i18n import I18n from paramecio.libraries.mtemplates import env_theme, PTemplate from paramecio.modules.admin2.models.admin import UserAdmin2, LoginTries2, PrivilegesModule2 from paramecio.libraries.db.webmodel import WebModel @@ -28,10 +28,6 @@ admin_app.install(check_login) env=env_theme(__file__) t=PTemplate(env) -gtext=PGetText(__file__) - -_=gtext.gettext - usermodel=UserAdmin2() usermodel.create_forms() @@ -68,9 +64,9 @@ def home_admin(session={}): #s=get_session() - #i18n=I18n('admin2') + i18n=I18n('admin2') - return t.load_template('layout.phtml', title=_('Admin'), module_selected='home_admin', session=session) + return t.load_template('layout.phtml', title=i18n.tlang('Admin'), module_selected='home_admin', session=session) #return {} @@ -103,9 +99,9 @@ def login_admin(session={}): db.close() - #i18n=I18n('admin2') + i18n=I18n('admin2') - return t.load_template('login.phtml', title=_('Login')) + return t.load_template('login.phtml', title=i18n.tlang('Login')) @admin_app.get('/signup', skip=[check_login], name='admin_app.signup_admin') def signup_admin(session={}): @@ -120,20 +116,20 @@ def signup_admin(session={}): db.close() - #i18n=I18n('admin2') + i18n=I18n('admin2') - return t.load_template('signup.phtml', title=_('Signup')) + return t.load_template('signup.phtml', title=i18n.tlang('Signup')) @admin_app.post('/login', skip=[check_login], name='admin_app.check_login_admin') def check_login_admin(session={}): db=WebModel.connection() - #i18n=I18n('admin2') + i18n=I18n('admin2') error=1 - message=_('Invalid user and password') + message=i18n.tlang('Invalid user and password') no_login=check_login_tries(request, db) @@ -183,21 +179,21 @@ def check_login_admin(session={}): sendmail=SendMail(ssl=True) - sendmail.send(config.portal_email, [result['email']], _('Code for complete login'), _('We send to you a code for activate your account using double authentication:')+"\n"+token_auth, content_type='plain', attachments=[]) + sendmail.send(config.portal_email, [result['email']], i18n.tlang('Code for complete login'), i18n.tlang('We send to you a code for activate your account using double authentication:')+"\n"+token_auth, content_type='plain', attachments=[]) if result['privileges']==0: with db.query('select module from privilegesmodule2 WHERE user_id=%s', [result['id']]) as cursor: modules_priv=[v['module'] for v in cursor.fetchall()] - for k, v in modules_admin.items(): - if k in modules_priv: + for v in modules_admin: + if v[0] in modules_priv: if len(v)>2: modules_priv+=v[2] else: modules_priv=[] - for k, v in modules_admin.items(): - modules_priv.append(k) + for v in modules_admin: + modules_priv.append(v[0]) if len(v)==3: modules_priv+=v[2] @@ -221,7 +217,7 @@ def check_login_admin(session={}): @admin_app.post('/signup', skip=[check_login], name='admin_app.signup_insert_admin') def signup_insert_admin(session={}): - #i18n=I18n('admin2') + i18n=I18n('admin2') error=1 @@ -260,7 +256,7 @@ def signup_insert_admin(session={}): error=0 message="User added!" else: - message=_('Sorry, cannot create the new user') + message=i18n.tlang('Sorry, cannot create the new user') db.close() @@ -315,9 +311,9 @@ def change_theme(session={}): @admin_app.get('/need_auth', skip=[check_login], name='admin_app.need_auth') def need_auth(session={}): - #i18n=I18n('admin2') + i18n=I18n('admin2') - return t.load_template('need_auth.phtml', title=_('Auth check')) + return t.load_template('need_auth.phtml', title=i18n.tlang('Auth check')) @admin_app.post('/auth_check', skip=[check_login], name='admin_app.auth_check') def auth_check(session={}): diff --git a/paramecio/modules/admin2/ausers.py b/paramecio/modules/admin2/ausers.py index 637ca47..708becc 100644 --- a/paramecio/modules/admin2/ausers.py +++ b/paramecio/modules/admin2/ausers.py @@ -2,7 +2,7 @@ from paramecio.modules.admin2.models.admin import UserAdmin2 from paramecio.modules.admin2.app import admin_app from paramecio.modules.admin2.libraries.config import modules_admin, modules_admin_icons from paramecio.libraries.mtemplates import PTemplate, env_theme -from paramecio.libraries.i18n import I18n, PGetText +from paramecio.libraries.i18n import I18n import paramecio.modules.admin2.libraries.i18n as i18n_lang import os #from paramecio.libraries.lists import SimpleList @@ -21,12 +21,7 @@ env=env_theme(__file__) t=PTemplate(env) -#i18n=I18n('admin2') - -gtext=PGetText(__file__) - -_=gtext.gettext - +i18n=I18n('admin2') #t.env.directories=admin_t.env.directories """ @@ -37,13 +32,9 @@ if t.env.directories[1]!=tpl_path: """ #modules_admin.append(['menu_users', 'people-circle', True]) -def admin_users(): - - return _('Admin users') +modules_admin.append(['admin_app.admin_users', 'people-circle', ['admin_app.admin_permissions']]) -modules_admin['admin_app.admin_users']=[admin_users, 'people-circle', ['admin_app.admin_permissions']] - -modules_admin_icons['admin_app.admin_users']='' +modules_admin_icons.append('') @admin_app.get('/ausers', name="admin_app.admin_users") @admin_app.post('/ausers', name="admin_app.admin_users") @@ -63,11 +54,11 @@ def admin_users(session={}): user_admin.create_forms(['username', 'password', 'email', 'privileges', 'lang', 'dark_theme', 'double_auth']) - user_admin.forms['privileges'].arr_select={0: _('Without privileges'), 1: _('Selected privileges'), 2: _('Administrator')} + user_admin.forms['privileges'].arr_select={0: I18n.lang('admin', 'without_privileges', 'Without privileges'), 1: I18n.lang('admin', 'selected_privileges', 'Selected privileges'), 2: I18n.lang('admin', 'administrator', 'Administrator')} - user_admin.forms['dark_theme'].arr_select={0: _('Light theme'), 1: _('Dark theme')} + user_admin.forms['dark_theme'].arr_select={0: i18n.tlang('Light theme'), 1: i18n.tlang('Dark theme')} - user_admin.forms['double_auth'].arr_select={0: _('No'), 1: _('Yes')} + user_admin.forms['double_auth'].arr_select={0: i18n.tlang('No'), 1: i18n.tlang('Yes')} user_admin.fields['password'].protected=False @@ -87,7 +78,7 @@ def admin_users(session={}): db.close() - return t.load_template('users.phtml', title=_('Admin users'), tlang=_, module_selected='admin_app.admin_users', slist=slist, session=session) + return t.load_template('users.phtml', title=i18n.tlang('Admin users'), tlang=i18n.tlang, module_selected='admin_app.admin_users', slist=slist, session=session) @admin_app.get('/ausers/permissions/', name="admin_app.admin_permissions") @admin_app.post('/ausers/permissions/', name="admin_app.admin_permissions") @@ -113,14 +104,7 @@ def admin_permissions(user_id, session={}): priv.fields['module'].name_form=SelectForm - #arr_modules={k:v[0] for k, v in modules_admin.items()} - arr_modules={} - - for k, v in modules_admin.items(): - if type(v[0]).__name__=='function': - arr_modules[k]=v[0]() - else: - arr_modules[k]=v[0] + arr_modules={v[0]:i18n.clang('admin2', v[0], v[0]) for v in modules_admin} priv.fields['user_id'].name_form=HiddenForm @@ -140,18 +124,18 @@ def admin_permissions(user_id, session={}): privileges_admin=admin.show() else: - arr_user={'username': _('User not found')} + arr_user={'username': i18n.tlang('User not found')} privileges_admin='' db.close() - return t.load_template('access.phtml', title=_('Users permissions'), privileges_admin=privileges_admin, user=arr_user, module_selected='admin_app.admin_users') + return t.load_template('access.phtml', title=i18n.tlang('Users permissions'), privileges_admin=privileges_admin, user=arr_user, module_selected='admin_app.admin_users') def user_options(url, id, arr_row): options=[] - options.append(''+_('Edit')+'') + options.append(''+I18n.lang('common', 'edit', 'Edit')+'') if not arr_row['privileges']: - options.append(f''+_('User access')+'') - options.append(''+_('Delete')+'') + options.append(f''+i18n.tlang('User access')+'') + options.append(''+I18n.lang('common', 'delete', 'Delete')+'') return options diff --git a/paramecio/modules/admin2/languages/admin2.pot b/paramecio/modules/admin2/languages/admin2.pot deleted file mode 100644 index fad7190..0000000 --- a/paramecio/modules/admin2/languages/admin2.pot +++ /dev/null @@ -1,107 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-21 00:00+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: templates/layout.phtml:79 -msgid "Applications" -msgstr "" - -#: templates/layout.phtml:103 ausers.py:64 -msgid "Dark theme" -msgstr "" - -#: app.py:73 -msgid "Admin" -msgstr "" - -#: app.py:108 -msgid "Login" -msgstr "" - -#: app.py:125 -msgid "Signup" -msgstr "" - -#: app.py:136 -msgid "Invalid user and password" -msgstr "" - -#: app.py:186 -msgid "Code for complete login" -msgstr "" - -#: app.py:186 -msgid "" -"We send to you a code for activate your account using double authentication:" -msgstr "" - -#: app.py:263 -msgid "Sorry, cannot create the new user" -msgstr "" - -#: app.py:320 -msgid "Auth check" -msgstr "" - -#: ausers.py:40 ausers.py:86 -msgid "Admin users" -msgstr "" - -#: ausers.py:62 -msgid "Without privileges" -msgstr "" - -#: ausers.py:62 -msgid "Selected privileges" -msgstr "" - -#: ausers.py:62 -msgid "Administrator" -msgstr "" - -#: ausers.py:64 -msgid "Light theme" -msgstr "" - -#: ausers.py:66 -msgid "No" -msgstr "" - -#: ausers.py:66 -msgid "Yes" -msgstr "" - -#: ausers.py:132 -msgid "User not found" -msgstr "" - -#: ausers.py:137 -msgid "Users permissions" -msgstr "" - -#: ausers.py:142 -msgid "Edit" -msgstr "" - -#: ausers.py:144 -msgid "User access" -msgstr "" - -#: ausers.py:145 -msgid "Delete" -msgstr "" diff --git a/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.mo b/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.mo deleted file mode 100644 index 4a214e3..0000000 Binary files a/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.mo and /dev/null differ diff --git a/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.po b/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.po deleted file mode 100644 index f0b2844..0000000 --- a/paramecio/modules/admin2/languages/en-US/LC_MESSAGES/admin2.po +++ /dev/null @@ -1,107 +0,0 @@ -# Paramecio admin2 language file -# Copyright (C) 2025 -# This file is distributed under the same license as the Paramecio package. -# Antonio de la Rosa , 2025. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: \n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-21 00:00+0100\n" -"PO-Revision-Date: 2025-03-21 00:02+0100\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: en_US\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.5\n" - -#: templates/layout.phtml:79 -msgid "Applications" -msgstr "Applications" - -#: templates/layout.phtml:103 ausers.py:64 -msgid "Dark theme" -msgstr "Dark theme" - -#: app.py:73 -msgid "Admin" -msgstr "Admin" - -#: app.py:108 -msgid "Login" -msgstr "Login" - -#: app.py:125 -msgid "Signup" -msgstr "Signup" - -#: app.py:136 -msgid "Invalid user and password" -msgstr "Invalid user and password" - -#: app.py:186 -msgid "Code for complete login" -msgstr "Code for complete login" - -#: app.py:186 -msgid "We send to you a code for activate your account using double authentication:" -msgstr "We send to you a code for activate your account using double authentication:" - -#: app.py:263 -msgid "Sorry, cannot create the new user" -msgstr "Sorry, cannot create the new user" - -#: app.py:320 -msgid "Auth check" -msgstr "Auth check" - -#: ausers.py:40 ausers.py:86 -msgid "Admin users" -msgstr "Admin users" - -#: ausers.py:62 -msgid "Without privileges" -msgstr "Without privileges" - -#: ausers.py:62 -msgid "Selected privileges" -msgstr "Selected privileges" - -#: ausers.py:62 -msgid "Administrator" -msgstr "Administrator" - -#: ausers.py:64 -msgid "Light theme" -msgstr "Light theme" - -#: ausers.py:66 -msgid "No" -msgstr "No" - -#: ausers.py:66 -msgid "Yes" -msgstr "Yes" - -#: ausers.py:132 -msgid "User not found" -msgstr "User not found" - -#: ausers.py:137 -msgid "Users permissions" -msgstr "Users permissions" - -#: ausers.py:142 -msgid "Edit" -msgstr "Edit" - -#: ausers.py:144 -msgid "User access" -msgstr "User access" - -#: ausers.py:145 -msgid "Delete" -msgstr "Delete" diff --git a/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.mo b/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.mo deleted file mode 100644 index 500c33a..0000000 Binary files a/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.mo and /dev/null differ diff --git a/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.po b/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.po deleted file mode 100644 index da2667d..0000000 --- a/paramecio/modules/admin2/languages/es-ES/LC_MESSAGES/admin2.po +++ /dev/null @@ -1,107 +0,0 @@ -# Paramecio admin2 language file -# Copyright (C) 2025 -# This file is distributed under the same license as the Paramecio package. -# Antonio de la Rosa , 2025. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: \n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-21 00:00+0100\n" -"PO-Revision-Date: 2025-03-21 00:03+0100\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: es_ES\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.5\n" - -#: templates/layout.phtml:79 -msgid "Applications" -msgstr "Aplicaciones" - -#: templates/layout.phtml:103 ausers.py:64 -msgid "Dark theme" -msgstr "Tema oscuro" - -#: app.py:73 -msgid "Admin" -msgstr "Admin" - -#: app.py:108 -msgid "Login" -msgstr "Login" - -#: app.py:125 -msgid "Signup" -msgstr "Registrarse" - -#: app.py:136 -msgid "Invalid user and password" -msgstr "Nombre de usuario o contraseña inválida" - -#: app.py:186 -msgid "Code for complete login" -msgstr "Código para completar login" - -#: app.py:186 -msgid "We send to you a code for activate your account using double authentication:" -msgstr "Te enviáremos un código para activar tu cuenta usando doble autenticación:" - -#: app.py:263 -msgid "Sorry, cannot create the new user" -msgstr "Lo siendo, no puedo crear el nuevo usuario." - -#: app.py:320 -msgid "Auth check" -msgstr "Verificar login" - -#: ausers.py:40 ausers.py:86 -msgid "Admin users" -msgstr "Administrar usuarios" - -#: ausers.py:62 -msgid "Without privileges" -msgstr "Sin privilegios" - -#: ausers.py:62 -msgid "Selected privileges" -msgstr "Privilegios seleccionados" - -#: ausers.py:62 -msgid "Administrator" -msgstr "Administrador" - -#: ausers.py:64 -msgid "Light theme" -msgstr "Thema luminoso" - -#: ausers.py:66 -msgid "No" -msgstr "No" - -#: ausers.py:66 -msgid "Yes" -msgstr "Sí" - -#: ausers.py:132 -msgid "User not found" -msgstr "Usuario no encontrado" - -#: ausers.py:137 -msgid "Users permissions" -msgstr "Permisos de usuario" - -#: ausers.py:142 -msgid "Edit" -msgstr "Editar" - -#: ausers.py:144 -msgid "User access" -msgstr "Acceso de usuario" - -#: ausers.py:145 -msgid "Delete" -msgstr "Borrar" diff --git a/paramecio/modules/admin2/libraries/config.py b/paramecio/modules/admin2/libraries/config.py index 6876eac..b362ec3 100644 --- a/paramecio/modules/admin2/libraries/config.py +++ b/paramecio/modules/admin2/libraries/config.py @@ -4,7 +4,7 @@ # ['Name of module admin', 'name_function_for_url_for', 'xml-icon'] -modules_admin={} +modules_admin=[] -modules_admin_icons={} +modules_admin_icons=[] diff --git a/paramecio/modules/admin2/templates/access.phtml b/paramecio/modules/admin2/templates/access.phtml index c30c154..289213f 100644 --- a/paramecio/modules/admin2/templates/access.phtml +++ b/paramecio/modules/admin2/templates/access.phtml @@ -1,7 +1,7 @@ <%inherit file="layout.phtml"/> <%block name="content">

${tlang('User')}: ${user['username'].capitalize()}

-

${_('Users')} >> ${_('Permissions')}

+

${tlang('Users')} >> ${tlang('Permissions')}

${privileges_admin|n} -

${_('Users')} >> ${_('Permissions')}

+

${tlang('Users')} >> ${tlang('Permissions')}

diff --git a/paramecio/modules/admin2/templates/layout.phtml b/paramecio/modules/admin2/templates/layout.phtml index 619a23d..6be8e40 100644 --- a/paramecio/modules/admin2/templates/layout.phtml +++ b/paramecio/modules/admin2/templates/layout.phtml @@ -44,7 +44,7 @@ lang_selected=session['lang'] - %for module_icon in modules_admin_icons.values(): + %for module_icon in modules_admin_icons: ${module_icon|n} @@ -76,27 +76,19 @@ lang_selected=session['lang']
- ${show_flash_message()|n} + <%block name="content">
diff --git a/paramecio/modules/admin2/templates/layout_bs.phtml b/paramecio/modules/admin2/templates/layout_bs.phtml new file mode 100644 index 0000000..0cab79d --- /dev/null +++ b/paramecio/modules/admin2/templates/layout_bs.phtml @@ -0,0 +1,123 @@ +<% + +from parameciofast.modules.fastadmin.libraries.config import modules_admin, modules_admin_icons +from parameciofast.libraries.i18n import I18n + +i18n=I18n('fastadmin') + +%> + + + + + + ${title} + + + <%block name="css"> + + <%block name="header_js"> + + + + + + + + %for module_icon in modules_admin_icons: + + ${module_icon|n} + + %endfor + + +
+
+
+
+

${tlang('Dashboard')}

+
+
+
+
+ +
+ + % for module in modules_admin: + + % endfor +
+ +
+
+ <%block name="content"> +
+
+ ${tlang('Welcome to admin')} +
+
+

${tlang('This is the admin section of your site.')}

+
+
+ +
+
+
+ +
+ +
+ + + + + <%block name="js"> + + + diff --git a/paramecio/modules/admin2/templates/login.phtml b/paramecio/modules/admin2/templates/login.phtml index 5d9dfdb..0ad1045 100644 --- a/paramecio/modules/admin2/templates/login.phtml +++ b/paramecio/modules/admin2/templates/login.phtml @@ -25,12 +25,12 @@ <%block name="content">
- ${_('Login')} + ${tlang('Login')}
- +
@@ -40,12 +40,12 @@
- ${_('Error: username or password invalid')} + ${tlang('Error: username or password invalid')}
- +
${csrf_token()|n} @@ -117,7 +117,7 @@ $('#loader-div').hide(); $('#login_submit').prop('disabled', false); - alert('${_("Error: please, try again later")}'); + alert('${tlang("Error: please, try again later")}'); }, }).done(function(data) { @@ -132,19 +132,19 @@ else { - $('#username_form').get(0).setCustomValidity("${_('Error: username or password invalid')}"); - $('#password_form').get(0).setCustomValidity("${_('Error: username or password invalid')}"); + $('#username_form').get(0).setCustomValidity("${tlang('Error: username or password invalid')}"); + $('#password_form').get(0).setCustomValidity("${tlang('Error: username or password invalid')}"); console.log(JSON.stringify(data)); if(data.no_login) { - $('#login_invalid').html("${_('Error: you try login excessive times, please wait some minutes for try again')}"); + $('#login_invalid').html("${tlang('Error: you try login excessive times, please wait some minutes for try again')}"); } else { - $('#login_invalid').html("${_('Error: username or password invalid')}"); + $('#login_invalid').html("${tlang('Error: username or password invalid')}"); } diff --git a/paramecio/modules/admin2/templates/need_auth.phtml b/paramecio/modules/admin2/templates/need_auth.phtml index d9f6f8b..7819aaf 100644 --- a/paramecio/modules/admin2/templates/need_auth.phtml +++ b/paramecio/modules/admin2/templates/need_auth.phtml @@ -2,30 +2,30 @@ <%block name="content">
- ${_('Auth code')} + ${tlang('Auth code')}
- +
- ${_('You need a valid code')} + ${tlang('You need a valid code')}
- + ${csrf_token()|n}
@@ -74,7 +74,7 @@ form.classList.add('was-validated'); alert(textStatus); $('#code_submit').prop('disabled', false); - $('#code_form').get(0).setCustomValidity("${_('Error, please try again later')}"); + $('#code_form').get(0).setCustomValidity("${tlang('Error, please try again later')}"); } }).done(function(data) { @@ -100,22 +100,22 @@ if(data.hasOwnProperty('disable')) { - //$('#code_error').html("${_('Error, your user is disabled, you need support of web administration')}"); - $('#code_form').get(0).setCustomValidity("${_('Error, your user is disabled, you need support of web administration')}"); + //$('#code_error').html("${tlang('Error, your user is disabled, you need support of web administration')}"); + $('#code_form').get(0).setCustomValidity("${tlang('Error, your user is disabled, you need support of web administration')}"); - $('#txt_error_code').html("${_('Error, your user is disabled, you need support of web administration')}"); + $('#txt_error_code').html("${tlang('Error, your user is disabled, you need support of web administration')}"); } else { - $('#code_form').get(0).setCustomValidity("${_('Error, wrong code')}"); - //$('#code_error').html("${_('Error, wrong code')}"); - $('#txt_error_code').html("${_('Error, wrong code')}"); + $('#code_form').get(0).setCustomValidity("${tlang('Error, wrong code')}"); + //$('#code_error').html("${tlang('Error, wrong code')}"); + $('#txt_error_code').html("${tlang('Error, wrong code')}"); } if(data.you_cannot_login) { - //$('#code_error').html("${_('Error, excessive tries, wait some minutes for login again')}"); - $('#code_form').get(0).setCustomValidity("${_('Error, excessive tries, wait some minutes for login again')}"); - $('#txt_error_code').html("${_('Error, excessive tries, wait some minutes for login again')}"); + //$('#code_error').html("${tlang('Error, excessive tries, wait some minutes for login again')}"); + $('#code_form').get(0).setCustomValidity("${tlang('Error, excessive tries, wait some minutes for login again')}"); + $('#txt_error_code').html("${tlang('Error, excessive tries, wait some minutes for login again')}"); } @@ -170,17 +170,17 @@ if(data.hasOwnProperty('disable')) { - $('#code_error').html("${_('Error, your user is disabled, you need support of web administration')}"); + $('#code_error').html("${tlang('Error, your user is disabled, you need support of web administration')}"); } else { - $('#code_error').html("${_('Error, wrong code')}"); + $('#code_error').html("${tlang('Error, wrong code')}"); } if(data.you_cannot_login) { - $('#code_error').html("${_('Error, excessive tries, wait some minutes for login again')}"); + $('#code_error').html("${tlang('Error, excessive tries, wait some minutes for login again')}"); } diff --git a/paramecio/modules/admin2/templates/signup.phtml b/paramecio/modules/admin2/templates/signup.phtml index a6105bf..2434e78 100644 --- a/paramecio/modules/admin2/templates/signup.phtml +++ b/paramecio/modules/admin2/templates/signup.phtml @@ -2,39 +2,39 @@ <%block name="content">
- ${_('Signup')} + ${tlang('Signup')}
- +
- ${_('You need a valid username')} + ${tlang('You need a valid username')}
- +
- ${_('You need an email')} + ${tlang('You need an email')}
- ${_('You need a password')} + ${tlang('You need a password')}
- +
- ${_('You need the same password in this field and not empty')} + ${tlang('You need the same password in this field and not empty')}
- + ${csrf_token()|n}
@@ -49,7 +49,7 @@ $(document).ready( function () { console.log('No match'); - $('#repeat_password_form').get(0).setCustomValidity("${_('Passwords doesn\'t match')}"); + $('#repeat_password_form').get(0).setCustomValidity("${tlang('Passwords doesn\'t match')}"); } else { @@ -105,7 +105,7 @@ $(document).ready( function () { $('#loader-div').hide(); $('#login_submit').prop('disabled', false); - alert('${_("Error: please, try again later")}'); + alert('${tlang("Error: please, try again later")}'); }, }).done(function(data) {