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

In India, make the default unit for sodium mg instead of g on product edit form on web and mobile app #10038

Closed
Tracked by #6540
stephanegigandet opened this issue Mar 27, 2024 · 1 comment · Fixed by #10041
Labels
good first issue Welcome to Open Food Facts. This issue should be approachable if you're new. Get in touch for help. 🇮🇳 India https://wiki.openfoodfacts.org/Local_Communities/IndianTeam/Country_Support Nutrients

Comments

@stephanegigandet
Copy link
Contributor

stephanegigandet commented Mar 27, 2024

Reported by krishanti on Slack: "Please consider setting the default unit for Sodium as mg instead of grams as that is the unit commonly seen on nutrition labels. While editing products I've seen that sometimes the unit is mistakenly ignored and the nutriscore becomes inaccurate"

in the taxonomies/nutrients.txt, we can define default units for ingredients for a specific country. e.g. this states that for energy, the default unit is kj in all countries except Canada and the US:

unit:en: kj
unit_ca:en: kcal
unit_us:en: kcal

There is some code in product_multilingual.pl that then uses it to display the right unit on the product edit form on the web site:

		if (exists_taxonomy_tag("nutrients", "zz:$nid")) {
			$nutriment_ref->{name} = display_taxonomy_tag($lc, "nutrients", "zz:$nid");
			# We may have a unit specific to the country (e.g. US nutrition facts table using the International Unit for this nutrient, and Europe using mg)
			$unit = get_property("nutrients", "zz:$nid", "unit_$cc:en")
				// get_property("nutrients", "zz:$nid", "unit:en") // 'g';
		}

This code should be moved to a function in Food.pm, and it should also be called in cgi/nutrients.pl so that we get the right unit for countries. /cgi/nutrients.pl is used by the OFF mobile app.

Part of

@himanshisrestha
Copy link
Contributor

I'll start working on this

@stephanegigandet stephanegigandet added the good first issue Welcome to Open Food Facts. This issue should be approachable if you're new. Get in touch for help. label Mar 27, 2024
@teolemon teolemon added 🇮🇳 India https://wiki.openfoodfacts.org/Local_Communities/IndianTeam/Country_Support Nutrients labels Mar 29, 2024
alexgarel pushed a commit that referenced this issue Apr 2, 2024
- Added unit_in:en: mg key value pair to the nutrients taxonomy
- Made a new subroutine in Food.pm named get_nutrient_unit
- added a test in food.t
- Fixes #10038
john-gom pushed a commit that referenced this issue May 24, 2024
- Added unit_in:en: mg key value pair to the nutrients taxonomy
- Made a new subroutine in Food.pm named get_nutrient_unit
- added a test in food.t
- Fixes #10038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Welcome to Open Food Facts. This issue should be approachable if you're new. Get in touch for help. 🇮🇳 India https://wiki.openfoodfacts.org/Local_Communities/IndianTeam/Country_Support Nutrients
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants