예제 #1
0
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
예제 #2
0
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]
예제 #3
0
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)
예제 #4
0
파일: ops.py 프로젝트: iasinDev/appcomposer
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()
예제 #5
0
def list_of_languages():
    return {
        key.split('_')[0]: value
        for key, value in obtain_languages().items()
    }
예제 #6
0
def list_of_languages():
    return { key.split('_')[0] : value for key, value in obtain_languages().items() }
예제 #7
0
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]