def api_languages(): ordered_dict = OrderedDict() languages = list(obtain_languages().iteritems()) languages.sort(lambda x1, x2 : cmp(x1[1], x2[1])) for lang_code, lang_name in languages: ordered_dict[lang_code] = lang_name resp = make_response(json.dumps(ordered_dict, indent = 4)) resp.content_type = 'application/json' return resp
def obtain_formatted_languages(existing_language_codes): languages = [(lang.split('_')[0], name) for lang, name in obtain_languages().items() if lang != 'en_ALL' and name != 'DEFAULT'] return [{ 'code': language, 'name': name } for language, name in languages if language not in existing_language_codes]
def select_translations(): app_url = request.args.get('app_url') language = request.args.get('lang') target = request.args.get('target') if app_url and language and target: return redirect(url_for('.api_translate', app_url = app_url, lang = language, target = target)) targets = obtain_groups() languages = list(obtain_languages().iteritems()) languages.sort(lambda x1, x2 : cmp(x1[1], x2[1])) return render_template("translator/select_translations.html", targets = targets, languages = languages)
import datetime from collections import defaultdict from sqlalchemy import func, or_ from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import joinedload_all from appcomposer import db from appcomposer.application import app from appcomposer.translator.languages import obtain_languages, obtain_groups from appcomposer.translator.suggestions import translate_texts from appcomposer.models import TranslatedApp, TranslationUrl, TranslationBundle, ActiveTranslationMessage, TranslationMessageHistory, TranslationKeySuggestion, TranslationValueSuggestion, GoLabOAuthUser, TranslationSyncLog, TranslationCurrentActiveUser, TranslationSubscription, TranslationNotificationRecipient DEBUG = False LANGUAGES = obtain_languages() GROUPS = obtain_groups() def get_golab_default_user(): default_email = app.config.get('TRANSLATOR_DEFAULT_EMAIL', '*****@*****.**') default_user = db.session.query(GoLabOAuthUser).filter_by(email = default_email).first() if default_user is None: default_user = GoLabOAuthUser(email = default_email, display_name = "AppComposer") db.session.add(default_user) try: db.session.commit() except IntegrityError: default_user = db.session.query(GoLabOAuthUser).filter_by(email = default_email).first() db.session.rollback() except: db.session.rollback()
def list_of_languages(): return { key.split('_')[0]: value for key, value in obtain_languages().items() }
def list_of_languages(): return { key.split('_')[0] : value for key, value in obtain_languages().items() }
def obtain_formatted_languages(existing_language_codes): languages = [ (lang.split('_')[0], name) for lang, name in obtain_languages().items() if lang != 'en_ALL' and name != 'DEFAULT'] return [ { 'code' : language, 'name' : name } for language, name in languages if language not in existing_language_codes]