Skip to content

Remove unused keys from all locale files #442

Closed as not planned
Closed as not planned

Description

@danrademacher

for #268, I removed a handful of keys from en.yml that we do not use, as shown in this commit:
OpenHistoricalMap/ohm-website@0b980c1#diff-44438ce218f5287c58d0017f965d888715635d94280669896f75841fbd7b4cd7L1917-L1955

We need to remove those same keys from all the files in this directory:
https://github.com/OpenHistoricalMap/ohm-website/tree/staging/config/locales

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.

Maybe https://pypi.org/project/ruamel.yaml/ or https://pypi.org/project/PyYAML/

Activity

  1. added
    internationalization
    on Sep 20, 2022
  2. gregallensworth commented on Sep 21, 2022

    @gregallensworth

    The target nodes to remove would be as follows. For each file XX is the language code (de es etc), which is also the root node of the YAML content.

    XX.site.about.copyright.legal_babble.credit_3_1_html
    XX.site.about.copyright.legal_babble.credit_4_html
    XX.site.about.copyright.legal_babble.more_2_html
    XX.site.about.copyright.legal_babble.contributors_at_html
    XX.site.about.copyright.legal_babble.contributors_au_html
    XX.site.about.copyright.legal_babble.contributors_ca_html
    XX.site.about.copyright.legal_babble.contributors_fi_html
    XX.site.about.copyright.legal_babble.contributors_fr_html
    XX.site.about.copyright.legal_babble.contributors_nl_html
    XX.site.about.copyright.legal_babble.contributors_nz_html
    XX.site.about.copyright.legal_babble.contributors_si_html
    XX.site.about.copyright.legal_babble.contributors_es_html
    XX.site.about.copyright.legal_babble.contributors_za_html
    XX.site.about.copyright.legal_babble.contributors_gb_html
    
  3. gregallensworth commented on Sep 21, 2022

    @gregallensworth

    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
  4. gregallensworth commented on Sep 21, 2022

    @gregallensworth

    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

    image

    image

    image

  5. added a commit that references this issue on Sep 21, 2022
  6. gregallensworth commented on Sep 21, 2022

    @gregallensworth

    See the new ohm-website branch gin-locale-cleanup which uses these new locale files.

    OpenHistoricalMap/ohm-website#122

  7. added theissue type on Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

internationalization

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions