def update_locale(): source_locale = 'en-US' locale = 'pl' module = 'homescreen' mpath = '/Users/zbraniecki/projects/mozilla/gaia/apps/homescreen' orig_file = read_file(os.path.join('data', locale, '%s.lol.orig' % module)) trans_file = read_file(os.path.join('data', locale, '%s.lol' % module)) source_file = read_file(os.path.join(mpath, 'locale', '%s.lol' % source_locale)) result = { 'nottranslated': {}, 'outdated': {}, 'obsolete': {}, 'added': {}, 'uptodate': {}, } p = parser.Parser() orig_lol = p.parse(orig_file) trans_lol = p.parse(trans_file) source_lol = p.parse(source_file) orig_dict = get_entity_dict(orig_lol) trans_dict = get_entity_dict(trans_lol) source_dict = get_entity_dict(source_lol) ldiff = l10ndiff.lists(orig_dict, trans_dict, values=False) for key in ldiff: print('%s: %s' % (key, ldiff[key]))
def update_locale(): source_locale = 'en-US' locale = 'pl' module = 'homescreen' mpath = '/Users/zbraniecki/projects/mozilla/gaia/apps/homescreen' orig_file = read_file(os.path.join('data', locale, '%s.lol.orig' % module)) trans_file = read_file(os.path.join('data', locale, '%s.lol' % module)) source_file = read_file( os.path.join(mpath, 'locale', '%s.lol' % source_locale)) result = { 'nottranslated': {}, 'outdated': {}, 'obsolete': {}, 'added': {}, 'uptodate': {}, } p = parser.Parser() s = serializer.Serializer() orig_lol = p.parse(orig_file) trans_lol = p.parse(trans_file) source_lol = p.parse(source_file) orig_dict = get_entity_dict(orig_lol) trans_dict = get_entity_dict(trans_lol) source_dict = get_entity_dict(source_lol) # deal with added/removed entities ldiff = l10ndiff.lists(trans_dict, source_dict, values=False) apply_ldiff(trans_lol, ldiff) # deal with modified entities ldiff = l10ndiff.lists(orig_dict, source_dict, values=True) ldiff2 = {} for key in ldiff: if 'present' in ldiff[key]['flags']: ldiff2[key] = ldiff[key] #print('%s: %s' % (key, ldiff2[key])) print('---') print(trans_lol) print('---') apply_ldiff(trans_lol, ldiff2) print('====') print(trans_lol) print('====')
def update_locale(): source_locale = 'en-US' locale = 'pl' module = 'homescreen' mpath = '/Users/zbraniecki/projects/mozilla/gaia/apps/homescreen' orig_file = read_file(os.path.join('data', locale, '%s.lol.orig' % module)) trans_file = read_file(os.path.join('data', locale, '%s.lol' % module)) source_file = read_file(os.path.join(mpath, 'locale', '%s.lol' % source_locale)) result = { 'nottranslated': {}, 'outdated': {}, 'obsolete': {}, 'added': {}, 'uptodate': {}, } p = parser.Parser() s = serializer.Serializer() orig_lol = p.parse(orig_file) trans_lol = p.parse(trans_file) source_lol = p.parse(source_file) orig_dict = get_entity_dict(orig_lol) trans_dict = get_entity_dict(trans_lol) source_dict = get_entity_dict(source_lol) # deal with added/removed entities ldiff = l10ndiff.lists(trans_dict, source_dict, values=False) apply_ldiff(trans_lol, ldiff) # deal with modified entities ldiff = l10ndiff.lists(orig_dict, source_dict, values=True) ldiff2 = {} for key in ldiff: if 'present' in ldiff[key]['flags']: ldiff2[key] = ldiff[key] #print('%s: %s' % (key, ldiff2[key])) print('---') print(trans_lol) print('---') apply_ldiff(trans_lol, ldiff2) print('====') print(trans_lol) print('====')