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

Translate raw product categories #224

Closed
raphodn opened this issue Jan 25, 2024 · 5 comments · Fixed by #273, #275 or #276
Closed

Translate raw product categories #224

raphodn opened this issue Jan 25, 2024 · 5 comments · Fixed by #273, #275 or #276

Comments

@raphodn
Copy link
Member

raphodn commented Jan 25, 2024

Story

Currently the list of categories is only limited to english : https://github.com/openfoodfacts/open-prices-frontend/blob/master/src/data/category-tags.json

See #30 on how it was initiated

the full json is here : https://static.openfoodfacts.org/data/taxonomies/categories.full.json

@dq18 dq18 linked a pull request Jan 30, 2024 that will close this issue
@dq18
Copy link
Collaborator

dq18 commented Jan 30, 2024

Current implementation idea.

The API to searchalicious (autocomplete endpoint) is called:

  • once at page mount (with a simple query "a")
    This is just to init the dropdown with 10 categories in the user language. It could be done with a hardcoded list. The main goal is to check that the API is responsive (a notification can be added to tell the user if not) and type something and gets frustrated if nothing is returned.
  • Everytime the user inputs something in autocomplete field. So for example if the user types "rad", it will call for "r", then "ra" and "rad"

The fetch returns a list of max 10 categories (max number can be changed) and this list will be shown in the autocomplete field.

Other implementation ideas

  • Have one big call to the API to get all categories in the user language and save them in a json file
    It seems to me that the API does not allow to get all categories yet. Potentially big json file(?). This would need to be implemented as a regular job. If done at language switching/first login, it won't be updated if the API gets new categories.
  • Have one big json file with all categories and all translations
    Could be massive. Would require a regular API call to update the json from API. I don't think that is implemented in API.

Please add more ideas if you have

@raphodn
Copy link
Member Author

raphodn commented Jan 30, 2024

Currently the categories-tags.json is only a subset of all the categories.
We could also add all the translations and put them all in the json.

@raphael0202 did the filtering. Could you share your script ? So that we can use it to add the other languages ?

Also in #87 : "With a script, by fetching all subcategories under "fruits" and "vegetables", with an additional manual curation step."

@raphael0202
Copy link
Contributor

raphael0202 commented Jan 30, 2024

I built it manually by fetching children of "fruits", "vegetables" and filtering this set.
If we use the autocomplete feature of search-a-licious, we won't be able to have this filtered set of categories.
One quicker way of doing this would be to add all translations to the JSON file. The full category taxonomy in JSON is not that big, so with a reduced set I think it's a reasonable approach.

@raphodn
Copy link
Member Author

raphodn commented Feb 6, 2024

@raphael0202 did you have a look at the script to filter the raw categories + translate them ?

@raphael0202
Copy link
Contributor

It looks good to me!
Keeping it front-end is good to me as long as the bundle size is reasonable.

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