States management - internationalisation issues

Dicussion related to internationalisation Internationalisation project notes

When setting up a local instance, on need to import some localisation files, including a file with the list of states (see for France: New version working with the seeds.rb from ofn_deployment · openfoodfoundation/l10n_fr@ee7c56c · GitHub)

##1- The notion of “states” in your local instance and the abbreviation used
The notion of “state” doesn’t exist in the same way in each country. In Australia for example the abbrevation VIC meaning Victoria states is a common way to describe the state (am I right?)
But in France for exemple, we don’t have "states’, we have two levels instead of one (French bureaucracy ;-)), “Region” and then “Département”, each Region have several départements. People identify themselves easily to the département, and this level is also more local than the Region one, so we decided to translate State by Département.
For exemple, in the Region “Normandy” in France, we have a département called “Calvados”, which is identified not by an abbreviation, but a number 14. So we talk about the département n°14, and that makes sense for the people locally.
This is really important as when an enterprise creates its profile, it has to choose a state and only the abbreviation are displayed! Also in the shop list, the state is described by the abbreviations.

The list of “states” in the French instance is the list of our départements, but by default this list is described with abbreviation 3 letter codes, which doesn’t make sense.

##2 The bugs in the process of adapting states to local context
So as a super admin I changed in the configuration panel the abbr by the number of the département, but two problems appeared:

1- When we upgraded the code or recovered the server (don’t remember), the list of states was duplicated we had the good one with the numbers, and the bad one with the abbreviations, so the system imported again the original seed file.
If I look at the code, it says that “if you don’t find PARIS in the states list, import the seeds”
l10n_fr/seeds.rb at ee7c56c77d233ef09155562f3a35595ed324dd14 · openfoodfoundation/l10n_fr · GitHub

– States

unless Spree::State.find_by_name ‘PARIS’
country = Spree::Country.find_by_name(‘France’)
puts “[db:seed] Seeding states for France”

BUT PARIS is in the states list already in the config panel, so I don’t understand why the seed list was imported again when we did the upgrade?
How to prevent the system to reimport the bad list again?
Can I change the seeds file New version working with the seeds.rb from ofn_deployment · openfoodfoundation/l10n_fr@ee7c56c · GitHub, and replace the abbr code by the meaningul number, so that if other French instances are deployed, they import something meaningful? Can there be other negative impacts that I don’t think about?

2- As we didn’t clean the base at once, some enterprises choose the wrong département when they registered, because within the back office, when you click on new enterprise, it’s not the abbreviation that are proposed to you, but the name of the state, so in that case it was twice the same name, so people would choose randomly basically, without knowing that one has a wrong abbreviation.

SO I went in the database and found the enterprises badly registered, and changed the states, so that I could delete the wrong states in the configuration panel.
But still, there are two states that I can’t delete, ALPES MARITIMES and VAL DE MARNE
(got system error message)

I don’t understand why, what links can prevent us from deleting those entries? I don’t think this info are in tables related to orders… so where? We did a request in the database and didn’t find anything…

Would be great if @maikel or @RohanM or @pmackay you could guide me in what to do, or maybe @Kirsten you have an idea as well? Thanks in advance!

This has been solved by François in France so I close the topic. Not sure why it happened so we’ll be careful at next upgrade.