Closed jfly closed 5 years ago
In the test at the bottom, the wca-states.json is fully correct, and the en.yml or i18n-country-translations
will need updating to match.
Since the wca states file is our source of truth, I highly support a test making sure what our country names under the en
locale matches the one in the json file!
We definitely should override the names in our English locale for those which don't match.
I don't think we should keep all the countries name in the locale file though, just those which need to be overridden.
I'll work on adding the test described above!
(CC-ing @Mollerz because this is something I know he cares about)
Right now, we have 3 places you can go to find the name of a country/state:
Countries.name
column in our databasename
attribute inwca-states.json
en.yml
or thei18n-country-translations
gem)We should drop the
Countries.name
column from the database. Whenever possible, we should not store human readable text in the database: it's not translatable! Unfortunately, we probably still have legacy PHP code that depends on this column existing, and I don't know that it's worth updating that code to do something different.I think it does make sense to keep the country names in
en.yml
and inwca-states.json
.en.yml
is easy for us to query for in a locale-aware way, and we have infrastructure in place to help people translate those strings. We don't have any such infrastructure in place forwca-states.json
, and I don't think we should add anything. It may be possible to remove the names fromwca-states.json
, but that might make the MD file we use to generatewca-states.json
impossible to read.One idea would be to add a new unit test that loops over the contents of
wca-states.json
and compares the names there to the English translations of the countries. That way, whenever we updatewca-states.json
, we are forced to also updateen.yml
accordingly. Here's a simple script that does that check:search.rb
```ruby templ = "%40s %40s %40s\n" printf templ, "Countries.name", "wca-states.json", "en.yml or `i18n-country-translations`" Country::WCA_STATES["states_lists"].map do |list| list["states"].map do |state| state_id = state["id"] || I18n.transliterate(state["name"]).tr("'", "_") country = Country.c_find(state_id) db_name = country.read_attribute(:name) wca_regs_name = state["name"] i18n_en_name = country.name if [db_name, wca_regs_name, i18n_en_name].to_set.length > 1 printf templ, db_name, wca_regs_name, i18n_en_name end end end ```