make localisation of results explicit

Localisation was previously done as part of the formatting but might
also be useful on its own when working with the results directly.
This commit is contained in:
Sarah Hoffmann
2023-05-24 18:12:34 +02:00
parent dcfb228c9a
commit f335e78d1e
8 changed files with 58 additions and 51 deletions

View File

@@ -179,11 +179,11 @@ class APIReverse:
return 0
if result:
result.localize(args.get_locales(api.config.DEFAULT_LANGUAGE))
output = api_output.format_result(
napi.ReverseResults([result]),
args.format,
{'locales': args.get_locales(api.config.DEFAULT_LANGUAGE),
'extratags': args.extratags,
{'extratags': args.extratags,
'namedetails': args.namedetails,
'addressdetails': args.addressdetails})
if args.format != 'xml':
@@ -236,11 +236,13 @@ class APILookup:
geometry_output=args.get_geometry_output(),
geometry_simplification=args.polygon_threshold or 0.0)
for result in results:
result.localize(args.get_locales(api.config.DEFAULT_LANGUAGE))
output = api_output.format_result(
results,
args.format,
{'locales': args.get_locales(api.config.DEFAULT_LANGUAGE),
'extratags': args.extratags,
{'extratags': args.extratags,
'namedetails': args.namedetails,
'addressdetails': args.addressdetails})
if args.format != 'xml':
@@ -320,10 +322,13 @@ class APIDetails:
if result:
locales = args.get_locales(api.config.DEFAULT_LANGUAGE)
result.localize(locales)
output = api_output.format_result(
result,
'json',
{'locales': args.get_locales(api.config.DEFAULT_LANGUAGE),
{'locales': locales,
'group_hierarchy': args.group_hierarchy})
# reformat the result, so it is pretty-printed
json.dump(json.loads(output), sys.stdout, indent=4, ensure_ascii=False)