api-documentation icon indicating copy to clipboard operation
api-documentation copied to clipboard

Document the API to retrieve all existing values of language specific fields for multilingual products

Open stephanegigandet opened this issue 6 years ago • 4 comments

For language specific fields such as product_name or generic_name, the fields parameter of the read API enables to request a specific language (e.g. product_name_fr), or to set a preferred list of languages.

This feature allows to request a new field [field name]_languages with a hash with all existing values:

&fields=generic_name_languages:

product: { generic_name_languages: { en: "Chocolate cookies", fr: "Biscuits au chocolat" },

stephanegigandet avatar May 05 '19 15:05 stephanegigandet

Pushed in production.

stephanegigandet avatar May 07 '19 07:05 stephanegigandet

Sorry @stephanegigandet I don't see any documentation about it. I can write it if you don't have time but it has to be documented before closing.

To be sure I understand well, could you give a real URL example?

CharlesNepote avatar May 07 '19 08:05 CharlesNepote

I found an example: https://world.openfoodfacts.org/api/v0/product/5425600101745.json&fields=product_name_languages (name in french and in german)

@stephanegigandet can you confirm the parameter only applies to products? So documentation should go in https://en.wiki.openfoodfacts.org/API/Read/Product, right?

So the documentation could be (between "Name" and "Barcode" sections):

===== List languages for product_name and generic_name fields =====

* https://world.openfoodfacts.org/api/v0/product/5425600101745.json&fields=product_name_languages

Returns all the languages and the corresponding values a field can have. Example:
<pre>
    "product_name_languages": {
        "fr": "Belgian mayonnaise",
        "de": "Mayonnaise mit Ei"
    }
</pre>

CharlesNepote avatar May 07 '19 13:05 CharlesNepote

@CharlesNepote : yes, that's only for products.

stephanegigandet avatar Jun 06 '19 17:06 stephanegigandet