Localization and Translations
The name and details of Items can be localized by setting the HTTP header Accept-Language
.
curl -X GET \--header 'Accept-Language: es' \--url 'https://api-beta.bite.ai/items/fe1ea63d-eaf3-43d1-b553-fa0f5b4962d3/'
The response will include a field translations
with the values for name and details. If no
translations are present for the current item than the translations
field will not present.
{"id": "fe1ea63d-eaf3-43d1-b553-fa0f5b4962d3","name": "Cottage Cheese","details": null,"description": null,"brand": null,"type": null,"text_ingredients": null,"ingredients": [],"translations": {"es": {"name": "Queso Requesón"}},"parents": [],"children": [{"id": "15caa85b-7830-488b-a149-1d979265e0b1","name": "Cottage Cheese","brand": null,"details": "lowfat (1-2% fat)","categorizations": {},"translations": {"es": {"name": "Queso Requesón","details": "bajo en grasa, 1-2% de grasa"}},"nutrition_available": true,"nutrition_count": 2,"is_generic": true,"is_private": false}],"nutrition_available": true,"nutrition_count": 2,"nutrition_facts": [],"is_private": false,"is_generic": true,"categorizations": {}}
The list of support languages and the format of the header value is described in the API reference.
The language code support regional variants like en-us
for English United States. When looking up
translations if no translation exists for a specific regional variant then a translation using
the language code will be used. For example, requesting the language en-us
will result in
translations look ups first in English United States and then English generic, en
.
Setting a Default Language for a User
Users can have one or more languages set by updating their preferences.
curl -X PATCH \--url 'https://api-beta.bite.ai/me/' \--data '{"languages": ["es"]}'