1
0
forked from 0ad/0ad

Remove more translator duplicates

While `creditTranslators.py` did already contain logic to remove
duplicate translator names, that logic didn't remove translator names
which only differed in their casing. As the removal was implemented
using an (unordered) `set`, the order of such duplicate names wasn't
deterministic and oscilated between the possible orders with different
invocations of `creditTranslators.py`, creating unnecessary changes to
`translators.json`.

This commit fixes that so that duplicate names are also removed when
they just differ in their casing and prefers the variant with has the
names starting with a capitalized letter.

Patch by: @Dunedan
Accepted by: @Stan
Differential Revision: https://code.wildfiregames.com/D5304
This was SVN commit r28152.
This commit is contained in:
Dunedan 2024-07-16 09:32:04 +00:00
parent 4a68486812
commit 0881583535

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2022 Wildfire Games.
# Copyright (C) 2024 Wildfire Games.
# This file is part of 0 A.D.
#
# 0 A.D. is free software: you can redistribute it and/or modify
@ -157,8 +157,15 @@ for lang in langs.keys():
poFile.close()
# Sort and remove duplicates
# Sorting should ignore case to have a neat credits list
langsLists[lang] = sorted(set(langsLists[lang]), key=lambda s: s.lower())
# Sorting should ignore case, but prefer versions of names starting
# with an upper case letter to have a neat credits list.
translators = {}
for name in sorted(langsLists[lang], reverse=True):
if name.lower() not in translators.keys():
translators[name.lower()] = name
elif name.istitle():
translators[name.lower()] = name
langsLists[lang] = sorted(translators.values(), key=lambda s: s.lower())
# Now insert the new data into the new JSON file
for (langCode, langList) in sorted(langsLists.items()):