The Clarifai API supports many languages in addition to English. These are represented as translations of the 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.
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.
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.
importcom.clarifai.grpc.api.*;importcom.clarifai.grpc.api.status.*;// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsMultiConceptResponse listConceptLanguagesResponse =stub.listConceptLanguages(ListConceptLanguagesRequest.newBuilder().setConceptId("charlie").build());if (listConceptLanguagesResponse.getStatus().getCode() !=StatusCode.SUCCESS) {thrownewRuntimeException("List concept languages failed, status: "+listConceptLanguagesResponse.getStatus());}
// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsstub.ListConceptLanguages( { concept_id:"charlie" }, metadata, (err, response) => {if (err) {thrownewError(err); }if (response.status.code !==10000) {thrownewError("List concepts failed, status: "+response.status.description); } });
# Insert here the initialization code as outlined on this page:# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionslist_concept_languages_response = stub.ListConceptLanguages( service_pb2.ListConceptLanguagesRequest( concept_id="charlie" ), metadata=metadata)if list_concept_languages_response.status.code != status_code_pb2.SUCCESS:raiseException("List concept failed, status: "+ list_concept_languages_response.status.description)
To get a single language translation you have for a concept you can get by the language code and concept id.
importcom.clarifai.grpc.api.*;importcom.clarifai.grpc.api.status.*;// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsMultiConceptResponse getConceptLanguageResponse =stub.getConceptLanguage(ListConceptLanguageRequest.newBuilder().setConceptId("charlie").setLanguage("ja").build());if (getConceptLanguageResponse.getStatus().getCode() !=StatusCode.SUCCESS) {thrownewRuntimeException("List concept languages failed, status: "+getConceptLanguageResponse.getStatus());}
// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsstub.GetConceptLanguage( { concept_id:"charlie", language:"ja" }, metadata, (err, response) => {if (err) {thrownewError(err); }if (response.status.code !==10000) {thrownewError("Get concepts failed, status: "+response.status.description); } });
# Insert here the initialization code as outlined on this page:# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsget_concept_language_response = stub.GetConceptLanguage( service_pb2.GetConceptLanguageRequest( concept_id="charlie", language="ja" ), metadata=metadata)if get_concept_langauge_response.status.code != status_code_pb2.SUCCESS:raiseException("Get concept failed, status: "+ get_concept_language_response.status.description)
To create a langauge translation for a concept you can POST that language translation.
importcom.clarifai.grpc.api.*;importcom.clarifai.grpc.api.status.*;// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsMultiConceptResponse postConceptLanguageResponse =stub.postConceptLanguage(PostConceptLanguageRequest.newBuilder().setConceptId("charlie").addConceptLanguages(ConceptLanguage.newBuilder().setId("ja").setName("ボスコ")).build());if (postConceptLanguageResponse.getStatus().getCode() !=StatusCode.SUCCESS) {thrownewRuntimeException("Post concept languages failed, status: "+postConceptLanguageResponse.getStatus());}
// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsstub.PostConceptLanguage( { concept_id:"charlie", concept_languages: [ { id:"ja", name:"ボスコ" } ] }, metadata, (err, response) => {if (err) {thrownewError(err); }if (response.status.code !==10000) {thrownewError("Get concepts failed, status: "+response.status.description); } });
# Insert here the initialization code as outlined on this page:# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsget_concept_language_response = stub.PostConceptLanguage( service_pb2.PostConceptLanguageRequest( concept_id="charlie", concept_languages=[resources_pb2.ConceptLanguages( id="ja", name="ボスコ" )] ), metadata=metadata)if get_concept_langauge_response.status.code != status_code_pb2.SUCCESS:raiseException("Get concept failed, status: "+ get_concept_language_response.status.description)
To update a langauge translation for a concept you can PATCH that language translation.
importcom.clarifai.grpc.api.*;importcom.clarifai.grpc.api.status.*;// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsMultiConceptResponse patchConceptLanguageResponse =stub.patchConceptLanguage(PatchConceptLanguageRequest.newBuilder().setAction("overwrite").setConceptId("charlie").addConceptLanguages(ConceptLanguage.newBuilder().setId("ja").setName("new name")).build());if (patchConceptLanguageResponse.getStatus().getCode() !=StatusCode.SUCCESS) {thrownewRuntimeException("Patch concept languages failed, status: "+patchConceptLanguageResponse.getStatus());}
// Insert here the initialization code as outlined on this page:// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsstub.PatchConceptLanguage( { action:"overwrite", concept_id:"charlie", concept_languages: [ { id:"ja", name:"new name" } ] }, metadata, (err, response) => {if (err) {thrownewError(err); }if (response.status.code !==10000) {thrownewError("Get concepts failed, status: "+response.status.description); } });
# Insert here the initialization code as outlined on this page:# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructionsget_concept_language_response = stub.PatchConceptLanguage( service_pb2.PatchConceptLanguageRequest( concept_id="charlie", concept_languages=[resources_pb2.ConceptLanguages( id="ja", name="new name" )], action="overwrite" ), metadata=metadata)if get_concept_langauge_response.status.code != status_code_pb2.SUCCESS:raiseException("Get concept failed, status: "+ get_concept_language_response.status.description)