mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 18:11:23 +01:00
Consolidate languages into constants file
This commit is contained in:
parent
4722ff98dc
commit
de0a99c9d9
@ -2,11 +2,10 @@ from config import config
|
||||
from .database import db
|
||||
from flask import Flask, render_template, request, session, url_for, redirect, jsonify
|
||||
from flask_sslify import SSLify
|
||||
from titanembeds.utils import rate_limiter, discord_api, socketio, babel, redis_store
|
||||
from titanembeds.utils import rate_limiter, discord_api, socketio, babel, redis_store, language_code_list
|
||||
from .blueprints import api, user, admin, embed, gateway
|
||||
import os
|
||||
from titanembeds.database import get_administrators_list
|
||||
from titanembeds.i18n import LANGUAGES
|
||||
import titanembeds.constants as constants
|
||||
from datetime import timedelta
|
||||
|
||||
@ -51,9 +50,9 @@ socketio.on_namespace(gateway.Gateway('/gateway'))
|
||||
@babel.localeselector
|
||||
def get_locale():
|
||||
param_lang = request.args.get("lang", None)
|
||||
if param_lang in LANGUAGES:
|
||||
if param_lang in language_code_list():
|
||||
return param_lang
|
||||
return request.accept_languages.best_match(LANGUAGES.keys())
|
||||
return request.accept_languages.best_match(language_code_list())
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
@ -14,7 +14,7 @@ QUERY_PARAMETERS = [
|
||||
{
|
||||
"name": "lang",
|
||||
"type": "language",
|
||||
"description": "Is your users multilingual? No worries, Titan can speak multiple languages! <a href=\"https://github.com/TitanEmbeds/Titan/blob/master/webapp/titanembeds/i18n.py\" target=\"_blank\">Check here</a> for a list of all language parameters Titan can support. <br> Wish Titan supported your language? Consider contributing to <a href=\"http://translate.titanembeds.com/\" target=\"_blank\">our CrowdIn project</a>!",
|
||||
"description": "Is your users multilingual? No worries, Titan can speak multiple languages! Check the about page for a list of all language parameters Titan can support. <br> Wish Titan supported your language? Consider contributing to <a href=\"http://translate.titanembeds.com/\" target=\"_blank\">our CrowdIn project</a>!",
|
||||
"example": "nl",
|
||||
"input": "text",
|
||||
},
|
||||
@ -72,4 +72,289 @@ QUERY_PARAMETERS = [
|
||||
"description": "Prefills the guest username field with the given username.",
|
||||
"example": "Rainbow%20Dash",
|
||||
},
|
||||
]
|
||||
|
||||
LANGUAGES = [
|
||||
{
|
||||
"code": "ca",
|
||||
"name_en": "Catalan",
|
||||
"name": "Català",
|
||||
"translators": [
|
||||
{
|
||||
"name": "jan",
|
||||
"crowdin_profile": "test83318",
|
||||
},
|
||||
{
|
||||
"name": "Jaime Muñoz Martín",
|
||||
"crowdin_profile": "jmmartin_5",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "da",
|
||||
"name_en": "Danish",
|
||||
"name": "Dansk",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Victor Fisker",
|
||||
"crowdin_profile": "victorfrb",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "de",
|
||||
"name_en": "German",
|
||||
"name": "Deutsche",
|
||||
"translators": [
|
||||
{
|
||||
"name": "futureyess22",
|
||||
"crowdin_profile": "futureyess22",
|
||||
},
|
||||
{
|
||||
"name": "Sascha Greuel",
|
||||
"crowdin_profile": "SoftCreatR",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "en",
|
||||
"name_en": "English",
|
||||
"name": "English",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Tornado1878",
|
||||
"crowdin_profile": "Tornado1878",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "es_ES",
|
||||
"name_en": "Spanish",
|
||||
"name": "Español",
|
||||
"translators": [
|
||||
{
|
||||
"name": "jmromero",
|
||||
"crowdin_profile": "jmromero",
|
||||
},
|
||||
{
|
||||
"name": "NeHoMaR",
|
||||
"crowdin_profile": "NeHoMaR",
|
||||
},
|
||||
{
|
||||
"name": "Jaime Muñoz Martín",
|
||||
"crowdin_profile": "jmmartin_5",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "fr",
|
||||
"name_en": "French",
|
||||
"name": "français",
|
||||
"translators": [
|
||||
{
|
||||
"name": "𝔻𝕣.𝕄𝕦𝕣𝕠𝕨",
|
||||
"crowdin_profile": "drmurow",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "hi",
|
||||
"name_en": "Hindi",
|
||||
"name": "हिंदी",
|
||||
"translators": [
|
||||
{
|
||||
"name": "jznsamuel",
|
||||
"crowdin_profile": "jasonsamuel88",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "hu",
|
||||
"name_en": "Hungarian",
|
||||
"name": "Magyar",
|
||||
"translators": [
|
||||
{
|
||||
"name": "János Erkli",
|
||||
"crowdin_profile": "erklijani0521",
|
||||
},
|
||||
{
|
||||
"name": "csongorhunt",
|
||||
"crowdin_profile": "csongorhunt",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "id",
|
||||
"name_en": "Indonesian",
|
||||
"name": "bahasa Indonesia",
|
||||
"translators": [
|
||||
{
|
||||
"name": "isaideureka",
|
||||
"crowdin_profile": "isaideureka",
|
||||
},
|
||||
{
|
||||
"name": "riesky",
|
||||
"crowdin_profile": "riesky",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "it",
|
||||
"name_en": "Italian",
|
||||
"name": "Italiano",
|
||||
"translators": [
|
||||
{
|
||||
"name": "dotJS",
|
||||
"crowdin_profile": "justdotJS",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "ja",
|
||||
"name_en": "Japanese",
|
||||
"name": "日本語",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Jacob Ayeni",
|
||||
"crowdin_profile": "MehItsJacob",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "nl",
|
||||
"name_en": "Dutch",
|
||||
"name": "Nederlands",
|
||||
"translators": [
|
||||
{
|
||||
"name": "jelle619",
|
||||
"crowdin_profile": "jelle619",
|
||||
},
|
||||
{
|
||||
"name": "Reeskikker",
|
||||
"crowdin_profile": "Reeskikker",
|
||||
},
|
||||
{
|
||||
"name": "SuperVK",
|
||||
"crowdin_profile": "SuperVK",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "pl",
|
||||
"name_en": "Polish",
|
||||
"name": "Polski",
|
||||
"translators": [
|
||||
{
|
||||
"name": "That Guy",
|
||||
"crowdin_profile": "maksinibob",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "pt_PT",
|
||||
"name_en": "Portuguese",
|
||||
"name": "Português",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Miguel Dos Reis",
|
||||
"crowdin_profile": "siersod",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "ro",
|
||||
"name_en": "Romanian",
|
||||
"name": "Română",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Andra",
|
||||
"crowdin_profile": "sarmizegetusa",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "sr",
|
||||
"name_en": "Serbian (Cyrillic)",
|
||||
"name": "Српски",
|
||||
"translators": [
|
||||
{
|
||||
"name": "\"adriatic\" Miguel Dos Reis",
|
||||
"crowdin_profile": "siersod",
|
||||
},
|
||||
{
|
||||
"name": "Ciker",
|
||||
"crowdin_profile": "CikerDeveloper",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "sr_CS",
|
||||
"name_en": "Serbian (Latin)",
|
||||
"name": "Српски",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Ciker",
|
||||
"crowdin_profile": "CikerDeveloper",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "sv_SE",
|
||||
"name_en": "Swedish",
|
||||
"name": "svenska",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Samuel Sandstrom",
|
||||
"crowdin_profile": "ssandstrom95",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "th",
|
||||
"name_en": "Thai",
|
||||
"name": "ไทย",
|
||||
"translators": [
|
||||
{
|
||||
"name": "Pantakarn Toopprateep",
|
||||
"crowdin_profile": "CardKunG",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "tr",
|
||||
"name_en": "Turkish",
|
||||
"name": "Türk",
|
||||
"translators": [
|
||||
{
|
||||
"name": "monomyth",
|
||||
"crowdin_profile": "monomyth",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "zh_Hans_CN",
|
||||
"name_en": "Chinese Simplified",
|
||||
"name": "简体中文",
|
||||
"translators": [
|
||||
{
|
||||
"name": "dotJS",
|
||||
"crowdin_profile": "justdotJS",
|
||||
},
|
||||
{
|
||||
"name": "myjourney in Steemit",
|
||||
"crowdin_profile": "myjourney",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"code": "zh_Hant_TW",
|
||||
"name_en": "Chinese Traditional",
|
||||
"name": "中国传统的",
|
||||
"translators": [
|
||||
{
|
||||
"name": "myjourney in Steemit",
|
||||
"crowdin_profile": "myjourney",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
@ -1,24 +0,0 @@
|
||||
LANGUAGES = {
|
||||
'ca': 'Català', # Catalan
|
||||
'da': 'Dansk', # Danish
|
||||
'de': 'Deutsche', # German
|
||||
'en_US': 'English',
|
||||
'es_ES': 'Español', # Spanish
|
||||
'fr': 'français', # French
|
||||
'hi': 'हिंदी', # Hindi
|
||||
'hu': "Magyar", # Hungarian
|
||||
'id': 'bahasa Indonesia', # Indonesian
|
||||
'it': 'Italiano', # Italian
|
||||
'ja': '日本語', # Japanese
|
||||
'nl': 'Nederlands', # Dutch
|
||||
'pl': 'Polski', # Polish
|
||||
'pt_PT': 'Português', # Portuguese
|
||||
'ro': 'Română', # Romanian
|
||||
'sr': 'Српски', # Serbian (Cyrillic)
|
||||
'sr_CS': 'Српски', # Serbian (Latin)
|
||||
'sv_SE': 'svenska', # Swedish
|
||||
'th': "ไทย", # Thai
|
||||
'tr': 'Türk', # Turkish
|
||||
'zh_Hans_CN': '简体中文', # Chinese Simplified
|
||||
'zh_Hant_TW': '中国传统的', # Chinese Traditional
|
||||
}
|
@ -340,148 +340,16 @@ We want to see all of our members rise to their potential and find success in th
|
||||
<div class="col s12">
|
||||
<div class="card-panel indigo lighten-5 z-depth-1">
|
||||
<ul>
|
||||
{% for language in constants.LANGUAGES %}
|
||||
<li>
|
||||
<span class="flow-text">Catalan (Català) [ca]</span>
|
||||
<span class="flow-text">{{ language["name_en"] }} ({{ language["name"] }}) [{{ language["code"] }}]</span>
|
||||
<ul class="browser-default">
|
||||
<li>jan (<a href="https://crowdin.com/profile/test83318" target="_blank">test83318</a>)</li>
|
||||
<li>Jaime Muñoz Martín (<a href="https://crowdin.com/profile/jmmartin_5" target="_blank">jmmartin_5</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Danish (Dansk) [da]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Victor Fisker (<a href="https://crowdin.com/profile/victorfrb" target="_blank">victorfrb</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">German (Deutsche) [de]</span>
|
||||
<ul class="browser-default">
|
||||
<li>futureyess22 (<a href="https://crowdin.com/profile/futureyess22" target="_blank">futureyess22</a>)</li>
|
||||
<li>Sascha Greuel (<a href="https://crowdin.com/profile/SoftCreatR" target="_blank">SoftCreatR</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">English (English) [en_US]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Tornado1878 (<a href="https://crowdin.com/profile/Tornado1878" target="_blank">Tornado1878</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Spanish (Español) [es_ES]</span>
|
||||
<ul class="browser-default">
|
||||
<li>jmromero (<a href="https://crowdin.com/profile/jmromero" target="_blank">jmromero</a>)</li>
|
||||
<li>NeHoMaR (<a href="https://crowdin.com/profile/NeHoMaR" target="_blank">NeHoMaR</a>)</li>
|
||||
<li>Jaime Muñoz Martín (<a href="https://crowdin.com/profile/jmmartin_5" target="_blank">jmmartin_5</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">French (français) [fr]</span>
|
||||
<ul class="browser-default">
|
||||
<li>𝔻𝕣.𝕄𝕦𝕣𝕠𝕨 (<a href="https://crowdin.com/profile/drmurow" target="_blank">drmurow</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Hindi (हिंदी) [hi]</span>
|
||||
<ul class="browser-default">
|
||||
<li>jznsamuel (<a href="https://crowdin.com/profile/jasonsamuel88" target="_blank">jasonsamuel88</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Hungarian (Magyar) [hu]</span>
|
||||
<ul class="browser-default">
|
||||
<li>János Erkli (<a href="https://crowdin.com/profile/erklijani0521" target="_blank">erklijani0521</a>)</li>
|
||||
<li>csongorhunt (<a href="https://crowdin.com/profile/csongorhunt" target="_blank">csongorhunt</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Indonesian (bahasa Indonesia) [id]</span>
|
||||
<ul class="browser-default">
|
||||
<li>isaideureka (<a href="https://crowdin.com/profile/isaideureka" target="_blank">isaideureka</a>)</li>
|
||||
<li>riesky (<a href="https://crowdin.com/profile/riesky" target="_blank">riesky</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Italian (Italiano) [it]</span>
|
||||
<ul class="browser-default">
|
||||
<li>dotJS (<a href="https://crowdin.com/profile/justdotJS" target="_blank">justdotJS</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Japanese (日本語) [ja]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Jacob Ayeni (<a href="https://crowdin.com/profile/MehItsJacob" target="_blank">MehItsJacob</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Dutch (Nederlands) [nl]</span>
|
||||
<ul class="browser-default">
|
||||
<li>jelle619 (<a href="https://crowdin.com/profile/jelle619" target="_blank">jelle619</a>)</li>
|
||||
<li>Reeskikker (<a href="https://crowdin.com/profile/Reeskikker" target="_blank">Reeskikker</a>)</li>
|
||||
<li>SuperVK (<a href="https://crowdin.com/profile/SuperVK" target="_blank">SuperVK</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Polish (Polski) [pl]</span>
|
||||
<ul class="browser-default">
|
||||
<li>That Guy (<a href="https://crowdin.com/profile/maksinibob" target="_blank">maksinibob</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Portuguese (Português) [pt_PT]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Miguel Dos Reis (<a href="https://crowdin.com/profile/siersod" target="_blank">siersod</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Romanian (Română) [ro]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Andra (<a href="https://crowdin.com/profile/sarmizegetusa" target="_blank">sarmizegetusa</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Serbian (Cyrillic) (Српски) [sr]</span>
|
||||
<ul class="browser-default">
|
||||
<li>"adriatic" Miguel Dos Reis (<a href="https://crowdin.com/profile/siersod" target="_blank">siersod</a>)</li>
|
||||
<li>Ciker (<a href="https://crowdin.com/profile/CikerDeveloper" target="_blank">CikerDeveloper</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Serbian (Latin) (Српски) [sr_CS]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Ciker (<a href="https://crowdin.com/profile/CikerDeveloper" target="_blank">CikerDeveloper</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Swedish (svenska) [sv_SE]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Samuel Sandstrom (<a href="https://crowdin.com/profile/ssandstrom95" target="_blank">ssandstrom95</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Thai (ไทย) [th]</span>
|
||||
<ul class="browser-default">
|
||||
<li>Pantakarn Toopprateep (<a href="https://crowdin.com/profile/CardKunG" target="_blank">CardKunG</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Turkish (Türk) [tr]</span>
|
||||
<ul class="browser-default">
|
||||
<li>monomyth (<a href="https://crowdin.com/profile/monomyth" target="_blank">monomyth</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Chinese Simplified (简体中文) [zh_Hans_CN]</span>
|
||||
<ul class="browser-default">
|
||||
<li>dotJS (<a href="https://crowdin.com/profile/justdotJS" target="_blank">justdotJS</a>)</li>
|
||||
<li>myjourney in Steemit (<a href="https://crowdin.com/profile/myjourney" target="_blank">myjourney</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="flow-text">Chinese Traditional (中国传统的) [zh_Hant_TW]</span>
|
||||
<ul class="browser-default">
|
||||
<li>myjourney in Steemit (<a href="https://crowdin.com/profile/myjourney" target="_blank">myjourney</a>)</li>
|
||||
{% for translator in language["translators"] %}
|
||||
<li>{{ translator["name"] }} (<a href="https://crowdin.com/profile/{{ translator["crowdin_profile"] }}" target="_blank">{{ translator["crowdin_profile"] }}</a>)</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>Wish Titan supported your language? Consider contributing to our <a href="http://translate.titanembeds.com/" target="_blank">CrowdIn project</a>! </p>
|
||||
</div>
|
||||
|
@ -1,4 +1,5 @@
|
||||
from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans, AuthenticatedUsers, GuildMembers, get_guild_member
|
||||
from titanembeds.constants import LANGUAGES
|
||||
from flask import request, session
|
||||
from flask_limiter import Limiter
|
||||
from flask_socketio import SocketIO
|
||||
@ -294,6 +295,12 @@ def guild_webhooks_enabled(guild_id):
|
||||
def guild_unauthcaptcha_enabled(guild_id):
|
||||
dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first()
|
||||
return dbguild.unauth_captcha
|
||||
|
||||
def language_code_list():
|
||||
codes = []
|
||||
for lang in LANGUAGES:
|
||||
codes.append(lang["code"])
|
||||
return codes
|
||||
|
||||
rate_limiter = Limiter(key_func=get_client_ipaddr) # Default limit by ip address
|
||||
socketio = SocketIO()
|
||||
|
Loading…
Reference in New Issue
Block a user