Skip to main content

Languages

Multilingual support in Clarifai


The Clarifai API supports many languages in addition to English. These are represented as translations of names of concepts so that when you search by concept name or get predictions from a model's concepts, you can utilize the language of your choice.

Supported Languages

The currently supported languages are listed below.

LanguageCode
Arabic (ar)ar
Bengali (bn)bn
Danish (da)da
German (de)de
English (en)en
Spanish (es)es
Finnish (fi)fi
French (fr)fr
Hindi (hi)hi
Hungarian (hu)hu
Italian (it)it
Japanese (ja)ja
Korean (ko)ko
Dutch (nl)nl
Norwegian (no)no
Punjabi (pa)pa
Polish (pl)pl
Portuguese (pt)pt
Russian (ru)ru
Swedish (sv)sv
Turkish (tr)tr
Chinese Simplified (zh)zh
Chinese Traditional (zh-TW)zh-TW

Default Language

When you create a new Application, you must specify a default language. This will be the default language concepts are returned in when you do not explicitly set a language in an API request.

You cannot change the default language. You can however change languages per request.

create new app

List Language Translations by Concept ID

You can see all the language translations for a given concept ID with a GET call. This call supports pagination.

Below is an example of how you would list language translations by concept ID.

info

The initialization code used in the following examples is outlined in detail on the client installation page.

#############################################################################
# In this section, we set the user authentication, app ID, and concept ID.
# Change these strings to run your own example.
#############################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change this to whatever concept you want to see its languages
CONCEPT_ID = 'cat'

##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

list_concept_languages_response = stub.ListConceptLanguages(
service_pb2.ListConceptLanguagesRequest(
user_app_id=userDataObject,
concept_id=CONCEPT_ID
),
metadata=metadata
)


if list_concept_languages_response.status.code != status_code_pb2.SUCCESS:
print(list_concept_languages_response.status)
raise Exception("List concept failed, status: " + list_concept_languages_response.status.description)

print(list_concept_languages_response)
JSON Output Example
status {
code: SUCCESS
description: "Ok"
req_id: "e3d3b16eccf82d3b5563a0a01eebc579"
}
concept_languages {
id: "en"
name: "Cat Name"
}

Get Specific Language Translation for a Concept

Below is an example of how to get a single language translation for a concept. You can get it by the language code and concept ID.

#######################################################################################
# In this section, we set the user authentication, app ID, concept ID and language.
# Change these strings to run your own example.
#######################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to whatever concept you want to get its language translation
CONCEPT_ID = 'cat'
CONCEPT_LANGUAGE = "en"

##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

get_concept_language_response = stub.GetConceptLanguage(
service_pb2.GetConceptLanguageRequest(
user_app_id=userDataObject,
concept_id=CONCEPT_ID,
language=CONCEPT_LANGUAGE
),
metadata=metadata
)

if get_concept_language_response.status.code != status_code_pb2.SUCCESS:
print(get_concept_language_response.status)
raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)

print(get_concept_language_response)
JSON Output Example
status {
code: SUCCESS
description: "Ok"
req_id: "ef625131675ba87841983c6e7f654e39"
}
concept_language {
id: "en"
name: "Cat Name"
}

Add a Language Translation for a Concept

Below is an example of how to create a language translation for a concept by POSTing that language translation.

################################################################################################
# In this section, we set the user authentication, app ID, concept ID, and language ID and name.
# Change these strings to run your own example.
################################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to whatever concept you want to add its language translation
CONCEPT_ID = 'charlie'
LANGUAGE_ID = "ja"
LANGUAGE_NAME = "ボスコ"

##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

get_concept_language_response = stub.PostConceptLanguages(
service_pb2.PostConceptLanguagesRequest(
user_app_id=userDataObject,
concept_id=CONCEPT_ID,
concept_languages=[resources_pb2.ConceptLanguage(
id=LANGUAGE_ID,
name=LANGUAGE_NAME
)]
),
metadata=metadata
)

if get_concept_language_response.status.code != status_code_pb2.SUCCESS:
print(get_concept_language_response.status)
raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)

print(get_concept_language_response)
JSON Output Example
status {
code: SUCCESS
description: "Ok"
req_id: "c5054cc812539059340a2275c3cb7cd5"
}
concept_languages {
id: "ja"
name: "\343\203\234\343\202\271\343\202\263"
}

Update a Language Translation for a Concept

Below is an example of how to update a language translation for a concept by PATCHing that language translation.

########################################################################################
# In this section, we set the user authentication, app ID, concept ID, and language ID
# and new name. Change these strings to run your own example.
########################################################################################

USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to whatever concept you want to update its language translation
CONCEPT_ID = 'charlie'
LANGUAGE_ID = "ja"
LANGUAGE_NAME = "new name"

##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

get_concept_language_response = stub.PatchConceptLanguages(
service_pb2.PatchConceptLanguagesRequest(
user_app_id=userDataObject,
concept_id=CONCEPT_ID,
concept_languages=[resources_pb2.ConceptLanguage(
id=LANGUAGE_ID,
name=LANGUAGE_NAME
)],
action="overwrite"
),
metadata=metadata
)

if get_concept_language_response.status.code != status_code_pb2.SUCCESS:
print(get_concept_language_response.status)
raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)

print(get_concept_language_response)
JSON Output Example
status {
code: SUCCESS
description: "Ok"
req_id: "779d702cbb303bcce4e469eb1d3552c2"
}
concept_languages {
id: "ja"
name: "new name"
}