Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible language & Country specification confusion #812

Open
M123-dev opened this issue Oct 9, 2023 · 2 comments
Open

Possible language & Country specification confusion #812

M123-dev opened this issue Oct 9, 2023 · 2 comments

Comments

@M123-dev
Copy link
Member

M123-dev commented Oct 9, 2023

Description

A recommendation from a SDK user on Slack:

Hello, it seems like there might be some inconsistency in the OpenFoodFact API. When I call saveProduct and provide the product object with lang: OpenFoodFactsLanguage.FRENCH and countries: OpenFoodFactsCountry.FRANCE.offTag, I would expect the API to save this information in the FRENCH field.
This means that if I subsequently call model.ingredientsTextInLanguages?[OpenFoodFactsLanguage.FRENCH], it should return the value I provided.
However, it appears that it saves the information in the OpenFoodFactsLanguage.ENGLISH field instead.

To make it work as expected, I also need to pass the parameters language: OpenFoodFactsLanguage.FRENCH and country: OpenFoodFactsCountry.FRANCE to the saveProduct function.

Ultimately, I understand that I don't need to specify a language and country on the Product object, so i've removed it.

Perhaps it would be a good idea to create another dedicated class or implementation for the saveProduct function and not manipulate Product object ?

We could (should?) remove the duplicate field but I think in addition the server side should fill those fields respectively if one of those is missing. Or am I missing something

@monsieurtanuki
Copy link
Contributor

@M123-dev More generally, the question is about read-only fields and the meaning of fields.

I believe lang is just the language used in the latest update. Not very useful, is it?
In that specific case, that would probably make sense to deprecate/remove lang.

A different solution would be to display warnings each time a non-null read-only field is saved, if relevant with the name of the related field that is read/write.

@M123-dev
Copy link
Member Author

That's a good solution until we find something better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants