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

Add new localized ProductField's #960

Open
monsieurtanuki opened this issue Aug 3, 2024 · 8 comments
Open

Add new localized ProductField's #960

monsieurtanuki opened this issue Aug 3, 2024 · 8 comments
Assignees
Labels

Comments

@monsieurtanuki
Copy link
Contributor

Why - Problem description

I've noticed new localized product fields:

  • conservation_conditions_fr
  • customer_service_fr

cf. https://fr.openfoodfacts.org/produit/3017620425035/nutella-ferrero.com?fields=conservation_conditions_fr,customer_service_fr

We should implement them as localized fields in ProductField and Product.

@AffanShaikhsurab
Copy link

AffanShaikhsurab commented Jan 13, 2025

i would love to work on this issue

@monsieurtanuki
Copy link
Contributor Author

Hi @AffanShaikhsurab!
That should be easy - once you've understood how things work in that project for multilanguage fields.
Good luck!

@AffanShaikhsurab
Copy link

AffanShaikhsurab commented Jan 19, 2025

I added the fields conservation_conditions_fr and customer_service_fr to the product object. However, I think the issue lies in the conservation_conditions field. The code seems to expect it to be of type List<dynamic> (probably because the field name is plural), but the data being returned is a String.

Here’s an example of the value being returned:
"conservation_conditions_fr": "A conserver au sec et à l'abri de la chaleur. Ne pas mettre au réfrigérateur."

The error we’re encountering is:
Error fetching product: TypeError: "A conserver au sec et à l'abri de la chaleur. Ne pas mettre au réfrigérateur..": type 'String' is not a subtype of type 'List<dynamic>?

How should we approach resolving this issue? Should we:

  1. Update the API/logic to return a List<String> instead of a single String for conservation_conditions_fr?
  2. Change the code logic to handle String instead of List<dynamic> for this specific case?
  3. Change ths conservation_conditions to conservation_condition

I am assuming the issues here please help me to solve the issue

@monsieurtanuki
Copy link
Contributor Author

I added the fields conservation_conditions_fr and customer_service_fr to the product object.

@AffanShaikhsurab That may be part of the problem: we don't care about specifically French labels, we want multilingual labels.
I should rather have mentioned https://fr.openfoodfacts.org/produit/3017620425035/nutella-ferrero.com?fields=conservation_conditions_languages,customer_service_languages

{
  "code": "3017620425035",
  "product": {
    "conservation_conditions_languages": {
      "fr": "A conserver au sec et à l'abri de la chaleur. Ne pas mettre au réfrigérateur."
    },
    "customer_service_languages": {
      "fr": "FERRERO FRANCE COMMERCIALE - Service Consommateurs, CS 90058 - 76136 MONT SAINT AIGNAN Cedex"
    }
  },
  "status": 1,
  "status_verbose": "product found"
}

Please use for conservation conditions and customer service the same logic as for product name, cf. https://fr.openfoodfacts.org/produit/3017620425035/nutella-ferrero.com?fields=conservation_conditions_languages,customer_service_languages,product_name_languages

{
  "code": "3017620425035",
  "product": {
    "conservation_conditions_languages": {
      "fr": "A conserver au sec et à l'abri de la chaleur. Ne pas mettre au réfrigérateur."
    },
    "customer_service_languages": {
      "fr": "FERRERO FRANCE COMMERCIALE - Service Consommateurs, CS 90058 - 76136 MONT SAINT AIGNAN Cedex"
    },
    "product_name_languages": {
      "de": "Nutella",
      "en": "Nutella",
      "es": "",
      "fr": "Nutella",
      "zh": "费列罗榛子巧克力酱"
    }
  },
  "status": 1,
  "status_verbose": "product found"
}

@AffanShaikhsurab
Copy link

Ohh Soory now I see the issue I will fix it asap

@AffanShaikhsurab
Copy link

i have added the customer_service_languages , conservation_conditions_languages properly but when regenerating the product.g.dart using the dart run build_runner build i am getting error in different files in model directory / . What should i do ?

@monsieurtanuki
Copy link
Contributor Author

i have added the customer_service_languages , conservation_conditions_languages properly

Cool!

when regenerating the product.g.dart using the dart run build_runner build i am getting error in different files in model directory / .

Strange, I've never seen that.

What should i do ?

As far as the current issue goes, please create a pull request with only the files needed - regardless of whatever failed generating unrelated files.
Unless you have a problem with product.g.dart too.

@AffanShaikhsurab
Copy link

AffanShaikhsurab commented Jan 22, 2025

After pulling the repository from GitHub, I did not delete any folder named .dart_tool/build.

However, I am encountering an error while generating product.g.dart using dart run build_runner build.

[INFO] Found 59 declared outputs which already exist on disk. This is likely because the.dart_tool/build folder was deleted, or you are submitting generated files to your source repository.
Delete these files?
1 - Delete
2 - Cancel build
3 - List conflicts
-------- after choosing 3
[INFO] Conflicts:
openfoodfacts|lib/src/model/agribalyse.g.dart
openfoodfacts|lib/src/model/badge_base.g.dart
openfoodfacts|lib/src/model/ecoscore_adjustments.g.dart
openfoodfacts|lib/src/model/ecoscore_data.g.dart
openfoodfacts|lib/src/model/events_base.g.dart
openfoodfacts|lib/src/model/ingredient.g.dart
openfoodfacts|lib/src/model/insight.g.dart
openfoodfacts|lib/src/model/key_stats.g.dart
openfoodfacts|lib/src/model/knowledge_panel.g.dart
openfoodfacts|lib/src/model/knowledge_panel_element.g.dart
openfoodfacts|lib/src/model/leaderboard_entry.g.dart
openfoodfacts|lib/src/model/localized_tag.g.dart
openfoodfacts|lib/src/model/ocr_ingredients_result.g.dart
openfoodfacts|lib/src/model/ocr_packaging_result.g.dart
openfoodfacts|lib/src/model/old_product_result.g.dart
openfoodfacts|lib/src/model/ordered_nutrient.g.dart
openfoodfacts|lib/src/model/ordered_nutrients.g.dart
openfoodfacts|lib/src/model/origins_of_ingredients.g.dart
openfoodfacts|lib/src/model/packaging.g.dart
openfoodfacts|lib/src/model/product.g.dart
openfoodfacts|lib/src/model/product_list.g.dart
openfoodfacts|lib/src/model/product_packaging.g.dart
openfoodfacts|lib/src/model/product_result_field.g.dart
openfoodfacts|lib/src/model/product_result_field_answer.g.dart
openfoodfacts|lib/src/model/product_result_v3.g.dart
openfoodfacts|lib/src/model/product_stats.g.dart
openfoodfacts|lib/src/model/product_tag.g.dart
openfoodfacts|lib/src/model/robotoff_question.g.dart
openfoodfacts|lib/src/model/search_result.g.dart
openfoodfacts|lib/src/model/spelling_corrections.g.dart
openfoodfacts|lib/src/model/status.g.dart
openfoodfacts|lib/src/model/taxonomy_additive.g.dart
openfoodfacts|lib/src/model/taxonomy_allergen.g.dart
openfoodfacts|lib/src/model/taxonomy_category.g.dart
openfoodfacts|lib/src/model/taxonomy_country.g.dart
openfoodfacts|lib/src/model/taxonomy_ingredient.g.dart
openfoodfacts|lib/src/model/taxonomy_label.g.dart
openfoodfacts|lib/src/model/taxonomy_language.g.dart
openfoodfacts|lib/src/model/taxonomy_nova.g.dart
openfoodfacts|lib/src/model/taxonomy_origin.g.dart
openfoodfacts|lib/src/model/taxonomy_packaging.g.dart
openfoodfacts|lib/src/model/taxonomy_packaging_material.g.dart
openfoodfacts|lib/src/model/taxonomy_packaging_recycling.g.dart
openfoodfacts|lib/src/model/taxonomy_packaging_shape.g.dart
openfoodfacts|lib/src/model/user.g.dart
openfoodfacts|lib/src/prices/get_locations_result.g.dart
openfoodfacts|lib/src/prices/get_prices_result.g.dart
openfoodfacts|lib/src/prices/get_price_products_result.g.dart
openfoodfacts|lib/src/prices/get_proofs_result.g.dart
openfoodfacts|lib/src/prices/get_users_result.g.dart
openfoodfacts|lib/src/prices/location.g.dart
openfoodfacts|lib/src/prices/price.g.dart
openfoodfacts|lib/src/prices/price_product.g.dart
openfoodfacts|lib/src/prices/price_total_stats.g.dart
openfoodfacts|lib/src/prices/price_user.g.dart
openfoodfacts|lib/src/prices/proof.g.dart
openfoodfacts|lib/src/prices/session.g.dart
openfoodfacts|lib/src/search/autocomplete_search_result.g.dart
openfoodfacts|lib/src/search/autocomplete_single_result.g.dart

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

No branches or pull requests

2 participants