diff --git a/webapp/titanembeds/app.py b/webapp/titanembeds/app.py index 8564c41..77ff353 100644 --- a/webapp/titanembeds/app.py +++ b/webapp/titanembeds/app.py @@ -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(): diff --git a/webapp/titanembeds/constants.py b/webapp/titanembeds/constants.py index 98c7e41..2535de9 100644 --- a/webapp/titanembeds/constants.py +++ b/webapp/titanembeds/constants.py @@ -14,7 +14,7 @@ QUERY_PARAMETERS = [ { "name": "lang", "type": "language", - "description": "Is your users multilingual? No worries, Titan can speak multiple languages! Check here for a list of all language parameters Titan can support.
Wish Titan supported your language? Consider contributing to our CrowdIn project!", + "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.
Wish Titan supported your language? Consider contributing to our CrowdIn project!", "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", + }, + ], + }, ] \ No newline at end of file diff --git a/webapp/titanembeds/i18n.py b/webapp/titanembeds/i18n.py deleted file mode 100644 index a2e426e..0000000 --- a/webapp/titanembeds/i18n.py +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/webapp/titanembeds/templates/about.html.j2 b/webapp/titanembeds/templates/about.html.j2 index 3258801..4daa509 100644 --- a/webapp/titanembeds/templates/about.html.j2 +++ b/webapp/titanembeds/templates/about.html.j2 @@ -340,148 +340,16 @@ We want to see all of our members rise to their potential and find success in th

Wish Titan supported your language? Consider contributing to our CrowdIn project!

diff --git a/webapp/titanembeds/utils.py b/webapp/titanembeds/utils.py index 889842d..39e0ff1 100644 --- a/webapp/titanembeds/utils.py +++ b/webapp/titanembeds/utils.py @@ -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()