Use a geocoded Town only when the JSON town matches one of the stored translations

Open Beginner friendly
#242 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
swift
Domain
frontend

Research direction

Start in Photo Club Hub HTML/Ignite/Level 1/OrganizationsPage+makeOrgTable.swift by reading the displayTown closure in makeClubRow and the in-memory sort nearby. Check how Organization.localizedAddresses provides translations across languages, then ensure display and sorting use the same resolved town value. Done when matching JSON towns use the page-language geocode, nonmatching towns retain the JSON label, and row order follows the displayed value.

Written by the indexing model from the issue text.

Description

Enhancement Localization

Follow-up to #159, which made the Clubs table use the geocoded localizedTown_ for all organization types.

Spec

For the Town cell in the generated organization tables:

  • If the JSON town matches any of that organization's stored translations exactly — i.e. any LocalizedAddress.localizedTown_ in any language — display the geocoded value for the page's language.
  • If it matches none of them, display the unlocalized JSON town (today's fallback).
Why

The match test separates translation from relabelling. If the JSON label is itself one of the names the geocoder holds for that place, then label and geocode agree on which name this place has, and showing another language's form of it is a genuine translation. If the label appears in none of them, the geocoder has resolved the coordinates to a larger or smaller area than the one specified — the absorbing municipality, or a hamlet inside the town — and the hand-maintained label should stand.

Note the comparison must be against the translations in all languages, not against Dutch. Fotografiska Berlin has JSON Berlin and geocoded NL Berlijn: an NL-only test would find no match and would stop localizing a museum that works correctly today.

Worked examples

Measured with full geocoding coverage (266 LocalizedAddress rows = 133 organizations × 2 languages):

Organization JSON town geo NL geo EN Match? EN page NL page
Tokyo club (hypothetical) Tokyo Tokio Tokyo ✓ via EN Tokyo Tokio (JA: 東京)
Fotografiska Berlin Berlin Berlijn Berlin ✓ via EN Berlin Berlijn
Fotomuseum Antwerpen Antwerpen Antwerpen Antwerp ✓ via NL Antwerp Antwerpen
Fotogroep Argus Den Bosch 's‑Hertogenbosch 's‑Hertogenbosch ✗ Den Bosch Den Bosch
Fotoclub BeFoAm Beilen Hijken Hijken ✗ Beilen Beilen

"Den Bosch" is the representative case: a correct, deliberate, colloquial name whose geocode returns the same string in both languages — no translation is on offer, only a relabelling.

Effect on today's data
  • 14 of the 15 clubs that #159 changed revert to their JSON label (the full list is in https://github.com/vdhamer/Photo-Club-Hub-HTML/issues/159#issuecomment-5216857582).
  • One club still changes: Fotokring Sint-Michielsgestel, whose JSON matches the NL geocode exactly, so EN renders the abbreviation St-Michielsgestel. Acceptable under this spec; a separate abbreviation question if it ever matters.
  • All 5 museums whose NL and EN town names genuinely differ keep localizing.
  • Wanroy keeps showing as Wanroy. That is a data error, corrected in the JSON via vdhamer/Photo-Club-Hub#810 — display logic should not mask it.
Where

Photo Club Hub HTML/Ignite/Level 1/OrganizationsPage+makeOrgTable.swift, the displayTown closure in makeClubRow:

let displayTown: String = {
    guard let language,
          let addr = club.localizedAddress(for: language),
          let localizedTown = addr.localizedTown_,
          // the JSON label must itself be one of the geocoder's names for this place
          club.localizedAddresses.contains(where: { $0.localizedTown_ == club.town })
    else { return String("\(club.town)".replacingUTF8Diacritics) }
    return localizedTown
}()

Organization.localizedAddresses is public (Organization+ComputedProperties.swift:187), so no package change is needed.

Two implementation notes:

  1. Sorting must use the same resolved value. The in-memory sort (same file, ~lines 71-75) reads localizedTown_ unconditionally. If display falls back to the JSON label while the sort does not, rows appear out of alphabetical order — the mismatch that existed before #159, reintroduced for exactly the rows this spec protects.
  2. The Country column is unaffected. Level 1 JSON has no country field, so there is no hand-maintained value to compare against; Country is geocoded-only and stays as is.
Dominant language
Swift
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vdhamer/Photo-Club-Hub-HTML

All issues in vdhamer/Photo-Club-Hub-HTML

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.