openfoodfacts / openfoodfacts-hungergames

One click Mini-Games for Open Food Facts for: categories, labels, weight, brands, logos… We'd need to port and improve nutrition and ingredients from the old version.
9 stars 14 forks source link

feat: Added link to products in category/label/etc #407

Closed sumana2001 closed 2 years ago

sumana2001 commented 2 years ago

What

Closes #405

Screenshots

Screenshot 2022-03-25 at 10 35 05 PM Screenshot 2022-03-25 at 10 35 17 PM Screenshot 2022-03-25 at 10 38 05 PM Screenshot 2022-03-25 at 10 35 31 PM

Fixes bug(s)

sumana2001 commented 2 years ago

@alexfauquette Does any of them look better? I think since it is an optional button and is to be clicked only in case of confusion, maybe we should put a box around it and just show it as a hyperlink. Let me know what you think?

Screenshot 2022-03-28 at 9 43 52 PM Screenshot 2022-03-28 at 9 45 50 PM

If you like any of them, I'll commit the changes accordingly.

alexfauquette commented 2 years ago

@sumana2001 "See examples of this label/category" sounds good.

A nice to have is the translation of your text. You probably noticed that all text in the interface is declared by {{ $t("gameKey.translationKey") }}. This is done with VueI18n. If you never used i18n tools, this can help you:

sumana2001 commented 2 years ago

Thanks, @alexfauquette for the resources. I have never really worked with i18n tools. I'll go through the links and try to implement it

sumana2001 commented 2 years ago

Hey @alexfauquette, I have added the translation key in common.json. But adding it only there is not working for me and showing the below output:

Screenshot 2022-03-28 at 11 17 08 PM

But when I added the translation key to en.json (the English file), it started working and showed the below output. When I changed the language to Italian, still I am getting the below output with the English text as the Italian key hasn't been added yet. So am I doing something wrong here? Or am I supposed to change the en.json file as well?

Screenshot 2022-03-28 at 11 16 30 PM
alexfauquette commented 2 years ago

Nothing bad

The fall back language is en so it will try to get translation from en.json https://github.com/alexfauquette/openfoodfacts-hungergames-1/blob/23ca2a0797e914497f04ef360f5e0a48a7944f46/src/main.js#L60-L64

const i18n = new VueI18n({
  locale: getLang(),
  messages,
  fallbackLocale: "en",
});

But the file common.json is the reference to let the community translate the app https://github.com/alexfauquette/openfoodfacts-hungergames-1/blob/master/crowdin.yml


project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
#
# Files configuration
#
files:
  - source: /src/i18n/common.json
    translation: /src/i18n/%two_letters_code%.json

So it should be in en.json to work immediately, and in common.json to let others translate it in its own language

sumana2001 commented 2 years ago

Oh, I understood now. So I am pushing the code in where I have changed both common.json and en.json. Thanks for the help.

alexfauquette commented 2 years ago

Nice 👍

alexgarel commented 2 years ago

wow kudos @sumana2001 (and @alexfauquette for the kind mentoring !)