snail icon indicating copy to clipboard operation
snail copied to clipboard

falls back to english if country not translated

Open dbaq opened this issue 8 years ago • 4 comments

hi @cainlevy,

In some rare cases, the translation might not be present (thinking about AF for instance). The fallback code to english was broken due to the match function. Also, if a country is not a valid iso code, we should display the raw value.

dbaq avatar Jun 20 '16 19:06 dbaq

Hi @dbaq! Apologies for the delay. I've been away for a bit.

Thanks for catching the bug in translated_country!

I'm unsure what to do with invalid country ISO codes though. I have two concerns:

  1. This is a backwards incompatible change. It changes the meaning of the country attribute.
  2. If Snail is provided an unknown country code, can it do its job? It won't be able to translate or provide correct formatting.

I have empathy for anyone relying on country name data (we did at one point as well) but I'm not convinced that Snail should support it. If the country names are provided by users, the system has no consistency or accuracy. If the names are enumerated, then the system should map them back to ISO codes for processing.

Thoughts? I can be persuaded.

cainlevy avatar Jul 19 '16 15:07 cainlevy

hey @cainlevy, just went through my open PR and found this one.

It's been a while but we have this PR in production since then. The bug fix for translated_country is useful.

If Snail is provided an unknown country code, can it do its job? It won't be able to translate or provide correct formatting.

It is correct, it is a pure design choice. Do you prefer throw an error or a graceful degradation? On my side, I always go try to go for graceful degradations.

On our side, why did/do we need it? I migrated 1M addresses from an open country input to a dropdown country list with the iso code as a key. I was able to map 65% of values to an iso code but at the time we still had to support other values. I understand your point of view but I think such a use case could be common and allow to fallback to default formatting and english is decent enough.

Let me know your thoughts.

dbaq avatar Nov 18 '16 05:11 dbaq

Okay, I've spent some time thinking about this and concluded that graceful degredation is the way to go because that's how the postal system works, too. Sending snail mail is all about making the best of imperfect data.

cainlevy avatar Dec 19 '16 17:12 cainlevy

Thanks for the review. I'll try to take a look at it soon.

dbaq avatar Dec 19 '16 22:12 dbaq