ldap-python-webui/libs/localization.py
2023-04-07 15:21:44 +02:00

82 lines
4.0 KiB
Python

import os
import gettext
class LocalizeTo(object):
"""docstring for Session"""
def __init__(self, lang, conf):
super(LocalizeTo, self).__init__()
if not os.path.isdir(conf['locale']['dir'] + "/" + lang):
lang = conf['locale']['lang']
translate = gettext.translation('base', localedir=conf['locale']['dir'], languages=[lang])
translate.install()
_ = translate.gettext
#generic strings
str_00 = _("User")
str_01 = _("Username")
str_02 = _("Firstname")
str_03 = _("Surname")
str_04 = _("Password")
str_05 = _("Old password")
str_06 = _("New password")
str_07 = _("Confirm password")
str_08 = _("Email")
str_09 = _("edit")
str_10 = _("Login")
str_11 = _("Logout")
str_12 = _("Delete")
str_13 = _("Sign Up")
str_14 = _("Back")
str_15 = _("Update")
str_16 = _("Or Sign In")
str_17 = _("Or Sign Up")
str_18 = _("Invite code")
str_19 = _("Edit your fullname")
str_20 = _("Edit your email")
str_21 = _("Change your password")
str_22 = _("Delete your account")
str_23 = _("Welcome")
str_24 = _("Logs")
str_25 = _("Last login")
str_26 = _("Devices")
str_27 = _("show")
#messages
msg_00 = _("The session was closed.")
msg_01 = _("Welcome")
msg_02 = _("Username must be at least 3 characters long!")
msg_03 = _("Not allowed characters for the username field.")
msg_04 = _("Not allowed characters for the firstname field.")
msg_05 = _("Not allowed characters for the surname field.")
msg_06 = _("The code is invalid or has expired.")
msg_07 = _("Passwords do not match!")
msg_08 = _("The password must contain at least 8 characters, at least one number, a capital letter and a special character.")
msg_09 = _("Congratulations, your account has been created!")
msg_10 = _("Your first and last name have not been changed.")
msg_11 = _("Your firstname is a bit short, don't you think?")
msg_12 = _("Your surname is a bit short, don't you think?")
msg_13 = _("Your first and last name have been successfully updated.")
msg_14 = _("Invalid email address. Please try again.")
msg_15 = _("Email address has not been changed.")
msg_16 = _("Your email has been successfully updated.")
msg_17 = _("The password entered is the same as the current password.")
msg_18 = _("Password has been changed!")
msg_19 = _("Please, type your username for account deletion.")
msg_20 = _("Account successfully deleted!")
msg_21 = _("Username or password is incorrect!")
msg_22 = _("Unable to connect to the remote server.")
msg_23 = _("Encountered an unexpected error while communicating with the remote server.")
msg_24 = _("User already exists.")
msg_25 = _("Email already exists.")
msg_26 = _("Forgot your password? Please try again.")
msg_27 = _("The session has expired.")
msg_28 = _("Registration is currently closed. We apologize for the inconvenience.")
self.str = {'usr':str_00, 'usrn':str_01, 'fn':str_02, 'sn':str_03, 'pwd':str_04, 'old-pwd':str_05,
'new-pwd':str_06, 'conf-pwd':str_07, 'email':str_08, 'edit':str_09, 'login':str_10, 'log-out':str_11,
'del':str_12, 'sign-up':str_13, 'back':str_14, 'update':str_15, 'or-sign-in':str_16,
'or-sign-up':str_17, 'inv-code':str_18, 'edit-fn':str_19, 'edit-email':str_20, 'ch-pwd':str_21,
'del-account':str_22, 'welcome':str_23, 'logs':str_24, 'last-login':str_25, 'devices':str_26,
'show':str_27, 'pwd-pattern': msg_08}
self.msg = (msg_00, msg_01, msg_02, msg_03, msg_04, msg_05, msg_06, msg_07, msg_08, msg_09, msg_10, msg_11, msg_12, msg_13, msg_14, msg_15, msg_16, msg_17, msg_18, msg_19, msg_20, msg_21, msg_22, msg_23, msg_24, msg_25, msg_26, msg_27, msg_28)