Update Translation

- Adding Translation for Credits Page
 - Adding detection support for webpage
This commit is contained in:
Silversthorn 2022-03-05 12:01:36 +01:00
parent ff3da27333
commit 506129729e
10 changed files with 94 additions and 30 deletions

View File

@ -862,4 +862,13 @@ class Helpers:
return text[len(prefix):]
return text
@staticmethod
def getLangPage(text):
lang = text.split("_")[0]
region = text.split("_")[1]
if region == 'EN':
return 'en'
else:
return lang+"-"+region
helper = Helpers()

View File

@ -251,6 +251,7 @@ class PanelHandler(BaseHandler):
'error': error,
'time': formatted_time,
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"]),
'lang_page': helper.getLangPage(self.controller.users.get_user_lang_by_id(exec_user["user_id"])),
'super_user': superuser,
'api_key': {
'name': api_key.name,
@ -375,8 +376,6 @@ class PanelHandler(BaseHandler):
user_order.remove(server_id)
page_data['servers'] = page_servers
#num players is set to zero here. If we poll all servers while dashboard is loading it takes FOREVER. We leave this to the
#async polling once dashboard is served.
page_data['num_players'] = 0
@ -1596,7 +1595,8 @@ class PanelHandler(BaseHandler):
user_id = self.controller.users.add_user(username, password=password0, email=email, enabled=enabled, superuser=superuser)
user_data = {
"roles": roles,
'lang': lang
'lang': lang,
'lang_page': helper.getLangPage(lang),
}
user_crafty_data = {
"permissions_mask": permissions_mask,
@ -1682,7 +1682,10 @@ class PanelHandler(BaseHandler):
else:
self.set_status(404)
page_data = {'lang': helper.get_setting('language')}
page_data = {
'lang': helper.get_setting('language'),
'lang_page': helper.getLangPage(helper.get_setting('language')),
}
self.render(
"public/404.html",
translate=self.translator.translate,
@ -1704,7 +1707,8 @@ class PanelHandler(BaseHandler):
'user_data': exec_user,
'hosts_data': self.controller.management.get_latest_hosts_stats(),
'show_contribute': helper.get_setting("show_contribute_link", True),
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"])
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"]),
'lang_page': helper.getLangPage(self.controller.users.get_user_lang_by_id(exec_user["user_id"])),
}
if page == "remove_apikey":

View File

@ -39,7 +39,11 @@ class PublicHandler(BaseHandler):
error = bleach.clean(self.get_argument('error', "Invalid Login!"))
error_msg = bleach.clean(self.get_argument('error_msg', ''))
page_data = {'version': helper.get_version_string(), 'error': error, 'lang': helper.get_setting('language')}
page_data = {
'version': helper.get_version_string(),
'error': error, 'lang': helper.get_setting('language'),
'lang_page': helper.getLangPage(helper.get_setting('language'))
}
# sensible defaults
template = "public/404.html"

View File

@ -75,6 +75,7 @@ class ServerHandler(BaseHandler):
'menu_servers': defined_servers,
'show_contribute': helper.get_setting("show_contribute_link", True),
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"]),
'lang_page': helper.getLangPage(self.controller.users.get_user_lang_by_id(exec_user["user_id"])),
'api_key': {
'name': api_key.name,
'created': api_key.created,
@ -84,6 +85,7 @@ class ServerHandler(BaseHandler):
} if api_key is not None else None,
'superuser': superuser
}
if helper.get_setting("allow_nsfw_profile_pictures"):
rating = "x"
else:
@ -139,7 +141,8 @@ class ServerHandler(BaseHandler):
'version_data': "version_data_here", # TODO
'user_data': exec_user,
'show_contribute': helper.get_setting("show_contribute_link", True),
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"])
'lang': self.controller.users.get_user_lang_by_id(exec_user["user_id"]),
'lang_page': helper.getLangPage(self.controller.users.get_user_lang_by_id(exec_user["user_id"]))
}
if page == "command":

View File

@ -9,6 +9,7 @@ class StatusHandler(BaseHandler):
def get(self):
page_data = {}
page_data['lang'] = helper.get_setting('language')
page_data['lang_page'] = helper.getLangPage(helper.get_setting('language'))
page_data['servers'] = self.controller.servers.get_all_servers_stats()
for srv in page_data['servers']:
server_data = srv.get('server_data', False)

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ data['lang_page'] }}">
<head>
<!-- Required meta tags -->

View File

@ -3,7 +3,7 @@
{% block meta %}
{% end %}
{% block title %}Crafty Controller - Credits{% end %}
{% block title %}Crafty Controller - {{ translate('credits', 'pageTitle', data['lang']) }}{% end %}
{% block content %}
@ -13,8 +13,8 @@
<div class="row page-title-header">
<div class="col-12">
<div class="page-header">
<h4 class="page-title">Credits
<small>Without these people, you wouldn't have Crafty</small>
<h4 class="page-title">{{ translate('credits', 'pageTitle', data['lang']) }}
<small>{{ translate('credits', 'pageDescription', data['lang']) }}</small>
</h4>
</div>
</div>
@ -27,7 +27,7 @@
<div class="card">
<div class="card-body">
<div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="far fa-code"></i> &nbsp;Development Team</h4>
<h4 class="card-title"><i class="far fa-code"></i> &nbsp;{{ translate('credits', 'developmentTeam', data['lang']) }}</h4>
</div>
<div class="row">
{% for person in data['staff']['development'] %}
@ -97,7 +97,7 @@
</div> <!-- end of user row -->
<div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fa fa-book"></i> &nbsp;Support and Documentation Team</h4>
<h4 class="card-title"><i class="fa fa-book"></i> &nbsp;{{ translate('credits', 'supportTeam', data['lang']) }}</h4>
</div>
<div class="row">
@ -168,7 +168,7 @@
</div> <!-- end user row-->
<div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="far fa-server"></i> &nbsp;Retired Staff</h4>
<h4 class="card-title"><i class="far fa-server"></i> &nbsp;{{ translate('credits', 'retiredStaff', data['lang']) }}</h4>
</div>
<div class="row">
@ -248,13 +248,13 @@
<div class="col-lg-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h4 class="card-title">Patreon Supporters</h4>
<p class="card-description"> A huge <code>thank you</code>&nbsp; to our Patreon supporters! | <span style="color: #9365B8">Last Update: {{ data["lastUpdate"] }}</span></p>
<h4 class="card-title">{{ translate('credits', 'patreonSupporter', data['lang']) }}</h4>
<p class="card-description"> {{ translate('credits', 'hugeDesc', data['lang']) }} <code>{{ translate('credits', 'thankYou', data['lang']) }}</code>&nbsp; {{ translate('credits', 'patreonDesc', data['lang']) }} | <span style="color: #9365B8">{{ translate('credits', 'patreonUpdate', data['lang']) }} {{ data["lastUpdate"] }}</span></p>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Level</th>
<th>{{ translate('credits', 'patreonName', data['lang']) }}</th>
<th>{{ translate('credits', 'patreonLevel', data['lang']) }}</th>
</tr>
</thead>
<tbody>
@ -263,13 +263,13 @@
<td>{{ pat["name"] }}</td>
<td>
{% if pat["level"] == "Crafty Sustainer" %}
<span class="btn btn-sm btn-info mr-2">Sustainer</span>
<span class="btn btn-sm btn-info mr-2">{{ translate('credits', 'patreonSustainer', data['lang']) }}</span>
{% elif pat["level"] == "Crafty Advocate" %}
<span class="btn btn-sm btn-primary mr-2">Advocate</span>
<span class="btn btn-sm btn-primary mr-2">{{ translate('credits', 'patreonAdvocate', data['lang']) }}</span>
{% elif pat["level"] == "Crafty Supporter" %}
<span class="btn btn-sm btn-inverse-success mr-2">Supporter</span>
<span class="btn btn-sm btn-inverse-success mr-2">{{ translate('credits', 'patreonSubs', data['lang']) }}</span>
{% else %}
<span class="btn btn-sm btn-secondary mr-2">Other</span>
<span class="btn btn-sm btn-secondary mr-2">{{ translate('credits', 'patreonOther', data['lang']) }}</span>
{% end %}
</td>
</tr>
@ -284,13 +284,13 @@
<div class="col-lg-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h4 class="card-title">Language Translation</h4>
<p class="card-description"> A huge <code>thank you</code>&nbsp; to our community who translate! </p>
<h4 class="card-title">{{ translate('credits', 'translationTitle', data['lang']) }}</h4>
<p class="card-description"> {{ translate('credits', 'hugeDesc', data['lang']) }} <code>{{ translate('credits', 'thankYou', data['lang']) }}</code>&nbsp; {{ translate('credits', 'translationDesc', data['lang']) }} </p>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>{{ translate('credits', 'translationName', data['lang']) }}</th>
<th>{{ translate('credits', 'translator', data['lang']) }}</th>
</tr>
</thead>
<tbody>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ data['lang_page'] }}">
<head>
<!-- Required meta tags -->

View File

@ -510,6 +510,27 @@
"superUser": "Super User",
"deleteKeyConfirmation": "Do you want to delete this API key? This cannot be undone.",
"deleteKeyConfirmationTitle": "Remove API key ${keyId}?"
},
"credits": {
"pageTitle": "Credits",
"pageDescription": "Without these people, you wouldn't have Crafty",
"developmentTeam": "Development Team",
"supportTeam": "Support and Documentation Team",
"retiredStaff": "Retired Staff",
"hugeDesc": "A huge",
"thankYou": "THANK YOU",
"patreonSupporter": "Patreon Supporters",
"patreonDesc": "to our Patreon supporters!",
"patreonUpdate": "Last Update:",
"patreonName": "Name",
"patreonLevel": "Level",
"patreonSustainer": "Sustainer",
"patreonAdvocate": "Advocate",
"patreonSubs": "Supporter",
"patreonOther": "Other",
"translationTitle": "Language Translation",
"translationDesc": "to our community who translate!",
"translationName": "Name",
"translator": "Translators"
}
}

View File

@ -89,7 +89,7 @@
"allServers": "Tous les Serverus",
"server": "Serveur",
"actions": "Actions",
"world": "Monde",
"size": "Taille du Serveur",
"motd": "MOTD",
"version": "Version",
"status": "Statut",
@ -240,7 +240,7 @@
"options": "Options",
"restoring": "Restauration de la sauvegarde. Cela peut prendre un peu de temps. S'il vous plaît soyez patient.",
"restore": "Restaurer",
"confirmRestore": "Êtes-vous sûr de vouloir restaurer à partir de cette sauvegarde. Tous les fichiers du serveur actuel passeront à l'état de sauvegarde et seront irrécupérables.",,
"confirmRestore": "Êtes-vous sûr de vouloir restaurer à partir de cette sauvegarde. Tous les fichiers du serveur actuel passeront à l'état de sauvegarde et seront irrécupérables.",
"excludedBackups": "Dossiers Exclus : ",
"excludedChoose": "Choisir les dossiers à exclure de la sauvegarde",
"clickExclude": "Cliquer pour sélectionner les Exclusions",
@ -510,5 +510,27 @@
"superUser": "Super Utilisateur",
"deleteKeyConfirmation": "Es-tu sûr de vouloir supprimer cette clé API? Tu ne pourras plus revenir en arrière.",
"deleteKeyConfirmationTitle": "Supprimer la clé API ${keyId}?"
},
"credits": {
"pageTitle": "Crédits",
"pageDescription": "Sans ces personnes, vous n'auriez pas Crafty",
"developmentTeam": "Equipe de Développement",
"supportTeam": "Equipe de Support et de Documentation",
"retiredStaff": "Retraités de Crafty",
"hugeDesc": "Un Enorme",
"thankYou": "MERCI",
"patreonSupporter": "Soutiens Patreon",
"patreonDesc": "à nos Soutiens Patreon !",
"patreonUpdate": "Dernière mise à Jour :",
"patreonName": "Nom",
"patreonLevel": "Niveau",
"patreonSustainer": "Admirateur",
"patreonAdvocate": "Partisan",
"patreonSubs": "Supporter",
"patreonOther": "Autre",
"translationTitle": "Traductions",
"translationDesc": "à notre communauté qui traduit Crafty !",
"translationName": "Langue",
"translator": "Traducteurs"
}
}