You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think we can just REGEX these out of the files, since they could be any number of lines, like this UK example of 4 lines vs vs AST with only 3.
In theory, YML keys themselves are also only unique given their whole tree, though these few that we're getting rid of seem to be unique across the whole file
In any case, it would be good to see if we can use a proper YML tool to get rid of them.
My first attempt was with PyYAML, but results were not good. I'm making sure to work with a file where UTF-8 errors would be obvious, in this case French fr.yml The generated output from PyYAML wrote the strings as Python encoded strings and was wholly wrong. It also re-sequences the content, making it tougher to match content and compare output.
Should be:
delete_introduction: 'Vous pouvez supprimer votre compte OpenHistoricalMap en
utilisant le bouton ci-dessous. Veuillez prendre note des détails suivants :'
delete_profile: Vos informations de profil, y compris votre avatar, votre
description et votre emplacement de domicile seront retirés.
But is:
cancel: Annuler
confirm_delete: "\xCAtes-vous s\xFBr(e)\u202F?"
delete_account: Supprimer un compte
delete_display_name: "Votre nom affich\xE9 sera supprim\xE9 et pourra \xEA\
tre r\xE9utilis\xE9 pour d\u2019autres comptes."
As such, I changed over to ruamel.yaml and am getting results that off the cuff look a lot nicer.
Still a few quirks to work out, or to confirm as not problematic.
OHM originals have a "..." at the end of the file, which indicates the end of a YAML document even if the file content begins; ruamel does not output this
OHM originals quote the word "yes" when used as a key e.g. "yes": Voie aérienne but ruamel does not do this
the line break lengths before it wraps onto a new line, are different between OHM and ruamel; thus there are a lot of diffs which are simply two words being shifted to the next line (then 3 more lines, as two more words shift here to there to there); this seems harmless but will make a lot of diffs; if the wrap length could be tuned to minimize these diffs, that would save a lot of eyestrain in review
update: line lengths in the OHM files are not consistent, seem to vary between 85 and 95? no single number matches all of them to minimize diffs
some quoted multi-line are being given \ at the start of line, not in the OHM originals; see community_driven_html for an example
update: loaded the new files into ohm-website locally, confirmed that the YAML parses just fine
OHM versions (most of them) have comments at the top for author credits, as well as the "---" line indicating the start of a YAML document; ruamel output does not include these
And a few spots where the YAML files had duplicate keys within a section, which was a parsing error. Evidently the JS YAML parser used by OSM/OHM doesn't care, but this Python parser does. I'll remove the 1st entry from each such pair that I find, as the latter one clobbers the first.
These three duplicate keys were found in en.yml and en-GB.yml This seems to be the only case of them.
To be more clear about what this means:
these are upstream OSM bugs in these YAML files
so need to be fixed manually in those two files, before my strip-unused-strings script will work on them
Activity
gregallensworth commentedon Sep 21, 2022
The target nodes to remove would be as follows. For each file XX is the language code (
deesetc), which is also the root node of the YAML content.gregallensworth commentedon Sep 21, 2022
My first attempt was with PyYAML, but results were not good. I'm making sure to work with a file where UTF-8 errors would be obvious, in this case French
fr.ymlThe generated output from PyYAML wrote the strings as Python encoded strings and was wholly wrong. It also re-sequences the content, making it tougher to match content and compare output.Should be:
But is:
As such, I changed over to ruamel.yaml and am getting results that off the cuff look a lot nicer.
Still a few quirks to work out, or to confirm as not problematic.
"yes": Voie aériennebut ruamel does not do this\at the start of line, not in the OHM originals; seecommunity_driven_htmlfor an examplegregallensworth commentedon Sep 21, 2022
And a few spots where the YAML files had duplicate keys within a section, which was a parsing error. Evidently the JS YAML parser used by OSM/OHM doesn't care, but this Python parser does. I'll remove the 1st entry from each such pair that I find, as the latter one clobbers the first.
These three duplicate keys were found in
en.ymlanden-GB.ymlThis seems to be the only case of them.To be more clear about what this means:
OpenHistoricalMap/issues#442 cleaned up locale translation files
gregallensworth commentedon Sep 21, 2022
See the new ohm-website branch gin-locale-cleanup which uses these new locale files.
OpenHistoricalMap/ohm-website#122