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

Implement the API to change the default language of a product #1015

Open
g123k opened this issue Dec 11, 2024 · 5 comments
Open

Implement the API to change the default language of a product #1015

g123k opened this issue Dec 11, 2024 · 5 comments

Comments

@g123k
Copy link
Contributor

g123k commented Dec 11, 2024

TODO find this API ;)

@monsieurtanuki
Copy link
Contributor

cf #812

Not sure that field exists, or even the concept.
I cannot see that on the website.

@monsieurtanuki monsieurtanuki removed their assignment Dec 12, 2024
@g123k
Copy link
Contributor Author

g123k commented Dec 12, 2024

That's this field on the website
Image

@g123k g123k changed the title Implement the API to change the default langage of a product Implement the API to change the default language of a product Dec 12, 2024
@monsieurtanuki
Copy link
Contributor

@g123k We already support that field, it's ProductField.LANGUAGE.

For the record:

  • it doesn't look that important as it's not displayed in the website, except when you edit a product (and it's not that obvious either)
  • we kind of already set that value in Smoothie each time we change product details (cf. BackgroundTaskDetails), as it looked like it provided better results for multilingual texts (or rare cases of products with only monolingual settings, can't remember). We set it to the current app language.

@g123k
Copy link
Contributor Author

g123k commented Dec 12, 2024

@g123k We already support that field, it's ProductField.LANGUAGE.

For the record:

  • it doesn't look that important as it's not displayed in the website, except when you edit a product (and it's not that obvious either)
  • we kind of already set that value in Smoothie each time we change product details (cf. BackgroundTaskDetails), as it looked like it provided better results for multilingual texts (or rare cases of products with only monolingual settings, can't remember). We set it to the current app language.

Mmmm, in that case, the implementation may be incorrect.
When we add a new product, it probably needs to be the same as the front picture (or one of the pictures).
But after the product creation, we shouldn't change it (unless we implement the feature to change it).

@teolemon
Copy link
Member

It's basically lang

<select name="lang" id="lang">
                    
                        <option value="ab">Abkhaz</option>
                    

Also, if you select a new lang, we have a toggle to move images and data to main language that appears

<input class="move_data_and_images_to_main_language_checkbox" type="checkbox" id="move_en_data_and_images_to_main_language" name="move_en_data_and_images_to_main_language">
 
<div class="move_data_and_images_to_main_language" id="move_en_data_and_images_to_main_language_div" style="">
   <input class="move_data_and_images_to_main_language_checkbox" type="checkbox" id="move_en_data_and_images_to_main_language" name="move_en_data_and_images_to_main_language">
   <label for="move_en_data_and_images_to_main_language" class="checkbox_label">Move all data and selected photos in <span class="tab_language">English</span> to the main language of the product: <span class="main_language">Finnish</span></label><br>
   <div id="move_en_data_and_images_to_main_language_radio" style="display: block;">
      <input type="radio" id="move_en_data_and_images_to_main_language_replace" value="replace" name="move_en_data_and_images_to_main_language_mode" checked="" class="move_and_replace" style="margin-left:1rem;">
      <label for="move_en_data_and_images_to_main_language_replace" style="margin-top:0">Replace existing values and selected photos</label>
      <input type="radio" id="move_en_data_and_images_to_main_language_ignore" value="ignore" name="move_en_data_and_images_to_main_language_mode">
      <label for="move_en_data_and_images_to_main_language_ignore" style="margin-top:0">Keep existing values and selected photos</label><br>
   </div>
</div>

This is all processed when you hit save. I don't believe it's some JS magic, but given that, I might be wrong: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/html/js/product-multilingual.js#L1008

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

No branches or pull requests

3 participants