Example #1
0
def convert_public():
    #print('There requests are')
    #print(request.json)

    nativize = True
    preoptions = []
    postoptions = []

    if 'preoptions' in request.values:
        preoptions = request.values['preoptions'].split(',')

    if 'postoptions' in request.values:
        postoptions = request.values['postoptions'].split(',')

    if 'nativize' in request.values:
        if request.values['nativize'] == 'False' or request.values['nativize'] == 'false':
            nativize = False

    if 'source' not in request.values:
        source = auto_detect(request.values['text'])
        preoptions = detect_preoptions(request.values['text'], source)
    else:
        source = request.values['source']

    if 'text' in request.values:
        text = convert(source, request.values['target'], request.values['text'], nativize, preoptions, postoptions)
    else:
        text = ''

    return text
Example #2
0
def convert_plugin():
    source = request.json['source']
    preoptions = request.json['preOptions']
    #print(request.json['text'])

    if request.json['source'] == 'autodetect':
        source = auto_detect(request.json['text'], plugin = True)
        preoptions = detect_preoptions(request.json['text'], source)

    if source not in GeneralMap.Transliteration:
        text = convert(source, request.json['target'], request.json['text'], request.json['nativize'], preoptions, request.json['postOptions'])
    else:
        text = request.json['text']

    return text
Example #3
0
def detect_pre_request():
    return jsonify(detect_preoptions(request.json['text'], request.json['source']))