openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
169 stars 67 forks source link

Ensure we help people send the right country codes and language codes #233

Open teolemon opened 3 years ago

teolemon commented 3 years ago
monsieurtanuki commented 3 years ago

I think it's already fixed for languages: String lc being deprecated and OpenFoodFactsLanguage language being used instead.

A solution for countries would be to

@teolemon Is that correct? May I start coding that?

teolemon commented 3 years ago

We discussed that again last evening with @alexgarel and @jasmeet0817 and the consensus seemed to go for a server side fix. Here's the server side place where it happens: https://github.com/openfoodfacts/openfoodfacts-server/blob/12d65665d997902b6a4850f5c55ba313ed320150/cgi/product_jqm_multilingual.pl#L231

Trying to gather a few more opinions before answering

monsieurtanuki commented 3 years ago

@teolemon Understood. The legitimate question of fixing the potentially flawed data provided by the user is not in contradiction with my suggestion, though. Creating an enum would bring clarity to the code. For the moment all we say is that there's a parameter called cc, that it is a String and that it is optional. A parameter named OpenFoodFactsCountry? country is easier to understand.

monsieurtanuki commented 3 years ago

@teolemon #292 partially answers this issue, with explicit country codes. If the issue is more about an implicit country-to-default-language map, that's another story. Even more if this map is dealt with on the server side - what did you guys decide eventually? Please feel free to close this issue or to add specs.