def check_modifications(language, target): """ Retrieves the last modification date and the active users. """ app_url = request.values.get('app_url') update_user_status(language=language, target=target, app_url=app_url, user=current_golab_user()) data = get_user_status(language=language, target=target, app_url=app_url, user=current_golab_user()) # data = { # "modificationDate": "2015-07-07T23:20:08Z", # "modificationDateByOther": "2015-07-07T23:20:08Z", # "time_now": "2015/12/01T20:83:23Z", # 'collaborators': [ # { # 'name': 'Whoever', # 'md5': 'thisisafakemd5' # } # ] # } # return jsonify(**data)
def check_modifications(language, target): """ Retrieves the last modification date and the active users. """ app_url = request.values.get('app_url') update_user_status(language = language, target = target, app_url = app_url, user = current_golab_user()) data = get_user_status(language = language, target = target, app_url = app_url, user = current_golab_user()) # data = { # "modificationDate": "2015-07-07T23:20:08Z", # "modificationDateByOther": "2015-07-07T23:20:08Z", # "time_now": "2015/12/01T20:83:23Z", # 'collaborators': [ # { # 'name': 'Whoever', # 'md5': 'thisisafakemd5' # } # ] # } # return jsonify(**data)
def api_translate(language, target): app_url = request.args.get('app_url') errors = [] if not app_url: errors.append("'app_url' argument missing") if not language: errors.append("'lang' argument missing") if not target: errors.append("'target' argument missing") if errors: return '; '.join(errors), 400 translation_url, original_messages, metadata = extract_local_translations_url(app_url) translation = {} stored_translations, from_developer, automatic = retrieve_stored(translation_url, language, target) suggestions = retrieve_suggestions(original_messages, language, target, stored_translations) for key, original_message_pack in original_messages.iteritems(): value = original_message_pack['text'] stored = stored_translations.get(key, {}) current_suggestions = list(suggestions.get(key, [])) current_target = stored.get('value') if from_developer: can_edit = not stored.get('from_developer', True) else: can_edit = True translation[key] = { 'source' : value, 'target' : current_target, 'from_default' : stored.get('from_default', False), 'suggestions' : current_suggestions, 'can_edit' : can_edit } app_thumb = None name = None for repo_app in db.session.query(RepositoryApp).filter_by(url = app_url).all(): if repo_app.name is not None: name = repo_app.name if repo_app.app_thumb is not None: app_thumb = repo_app.app_thumb if name and app_thumb: break update_user_status(language, target, app_url, current_golab_user()) users_status = get_user_status(language, target, app_url, current_golab_user()) response = { 'url' : app_url, 'app_thumb' : app_thumb, 'name' : name, 'translation' : translation, 'modificationDate': users_status['modificationDate'], 'modificationDateByOther': users_status['modificationDateByOther'], 'automatic': automatic and not from_developer } if False: response = json.dumps(response, indent = 4) return "<html><body>%s</body></html>" % response return jsonify(**response)
def api_translate(language, target): if language == 'en_ALL': return "error: select other language (not English)" app_url = request.args.get('app_url') errors = [] if not app_url: errors.append("'app_url' argument missing") if not language: errors.append("'lang' argument missing") if not target: errors.append("'target' argument missing") if errors: return '; '.join(errors), 400 translation_url, original_messages, metadata = extract_local_translations_url( app_url) translation = {} stored_translations, from_developer, automatic = retrieve_stored( translation_url, language, target) suggestions = retrieve_suggestions(original_messages, language, target, stored_translations) for key, original_message_pack in original_messages.iteritems(): # We still store the message itself (useful for other things, such as storing and maintaining it # in MongoDB contacted by Shindig). However, we do not display these messages to the final user if not original_message_pack['same_tool']: continue value = original_message_pack['text'] stored = stored_translations.get(key, {}) current_suggestions = list(suggestions.get(key, [])) current_target = stored.get('value') if from_developer: can_edit = not stored.get('from_developer', True) else: can_edit = True if value: translation[key] = { 'source': value, 'target': current_target, 'from_default': stored.get('from_default', False), 'suggestions': current_suggestions, 'can_edit': can_edit, 'format': original_message_pack.get('format', 'plain'), } app_thumb = None name = None for repo_app in db.session.query(RepositoryApp).filter_by( url=app_url).all(): if repo_app.name is not None: name = repo_app.name if repo_app.app_thumb is not None: app_thumb = repo_app.app_thumb if name and app_thumb: break update_user_status(language, target, app_url, current_golab_user()) users_status = get_user_status(language, target, app_url, current_golab_user()) response = { 'url': app_url, 'app_thumb': app_thumb, 'name': name, 'translation': translation, 'modificationDate': users_status['modificationDate'], 'modificationDateByOther': users_status['modificationDateByOther'], 'automatic': automatic and not from_developer, 'preview': automatic, } if False: response = json.dumps(response, indent=4) return "<html><body>%s</body></html>" % response return jsonify(**response)
def api_translate(language, target): if language == 'en_ALL': return "error: select other language (not English)" app_url = request.args.get('app_url') errors = [] if not app_url: errors.append("'app_url' argument missing") if not language: errors.append("'lang' argument missing") if not target: errors.append("'target' argument missing") if errors: return '; '.join(errors), 400 translation_url, original_messages, metadata = extract_local_translations_url(app_url) translation = {} stored_translations, from_developer, automatic = retrieve_stored(translation_url, language, target) suggestions = retrieve_suggestions(original_messages, language, target, stored_translations) for key, original_message_pack in original_messages.iteritems(): # We still store the message itself (useful for other things, such as storing and maintaining it # in MongoDB contacted by Shindig). However, we do not display these messages to the final user if not original_message_pack['same_tool']: continue value = original_message_pack['text'] stored = stored_translations.get(key, {}) current_suggestions = list(suggestions.get(key, [])) current_target = stored.get('value') if from_developer: can_edit = not stored.get('from_developer', True) else: can_edit = True if value: translation[key] = { 'source' : value, 'target' : current_target, 'from_default' : stored.get('from_default', False), 'suggestions' : current_suggestions, 'can_edit' : can_edit, 'format': original_message_pack.get('format', 'plain'), } app_thumb = None name = None for repo_app in db.session.query(RepositoryApp).filter_by(url = app_url).all(): if repo_app.name is not None: name = repo_app.name if repo_app.app_thumb is not None: app_thumb = repo_app.app_thumb if name and app_thumb: break update_user_status(language, target, app_url, current_golab_user()) users_status = get_user_status(language, target, app_url, current_golab_user()) response = { 'url' : app_url, 'app_thumb' : app_thumb, 'name' : name, 'translation' : translation, 'modificationDate': users_status['modificationDate'], 'modificationDateByOther': users_status['modificationDateByOther'], 'automatic': automatic and not from_developer, 'preview': automatic, } if False: response = json.dumps(response, indent = 4) return "<html><body>%s</body></html>" % response return jsonify(**response)