Clarifai Guide
Clarifai Home
v7.11
v7.11
  • Welcome
  • Clarifai Basics
    • Start Here (5 mins or less!)
      • Your First AI Predictions (~1 min)
      • Your First Visual Search App (~1 min)
      • Your First Custom Model (~5 mins)
    • Key Terminology to Know
    • Applications
      • Create an Application
      • Application Settings
      • Collaboration
    • Authentication
      • App-Specific API Keys
      • Authorize
      • Personal Access Tokens
      • Scopes
      • 2FA
      • Roll-Based Access Control
    • Clarifai Community Quick Start
  • API Guide
    • Clarifai API Basics
      • Clarifai API Clients
        • gRPC vs HTTP Channels
      • Helpful API Resources
        • Using Postman with Clarifai APIs
    • Your Data
      • Datasets
        • Dataset Basics
        • Dataset Filters
        • Dataset Inputs
        • Dataset Versions
      • Supported Formats
      • Adding and Removing Data
      • Collectors
    • Making Predictions
      • Images
      • Video
      • Text
      • Prediction Parameters
      • Multilingual Classification
    • Creating and Managing Concepts
      • Create, Get, Update
      • Languages
      • Search by Concept
      • Knowledge Graph
    • Labeling Your Data
      • Annotations
      • Training Data
      • Positive and Negative Annotations
      • Tasks
      • Task Annotations
    • Creating and Training Models
      • Clarifai Models
      • Model Types
      • Custom Models
      • Custom Text Model
      • Create, Get, Update, Delete
      • Deep Training
    • Evaluating Models
      • Interpreting Evaluations
      • Improving Your Model
    • Creating Workflows
      • Base Workflows
      • Input Nodes
      • Setting Up Mesh Workflows
      • Common Workflows
        • Workflow Predict
        • Auto Annotation
        • Custom KNN Face Classifier Workflow
        • Visual Text Recognition
    • Search, Sort, Filter and Save
      • Search Overview
      • Combine or Negate
      • Filter
      • Rank
      • Index Images for Search
      • Legacy Search
        • Combine or Negate
        • Filter
        • Rank
        • Saved Searches
    • Advanced Topics
      • Status Codes
      • Patching
      • Pagination
      • Batch Predict CSV on Custom Text Model
      • Document Processing
  • Portal Guide
    • Clarifai Portal Basics
    • Your Data
      • Supported Formats
      • Exploring Your Data
        • Predictions
        • Annotations
        • Bulk Labeling
        • Proposals
        • Object Tracking
      • Collectors
    • Making Predictions
    • Creating and Managing Concepts
      • Create, Get, Update, Delete
      • Knowledge Graph
      • Languages
    • Labeling Your Data
      • Create a Task
      • Label Types
      • Labeling Tools
      • AI Assist
      • Workforce Management
      • Review
      • Training Data
      • Positive and Negative Annotations
    • Creating and Training Models
      • Training Basics
      • Clarifai Models
      • Custom Models
      • Model Types
      • Deep Training
    • Evaluating Models
      • Interpreting Evaluations
      • Improving Your Model
    • Creating Workflows
      • Input Nodes
      • Workflow Builder
      • Base Workflows
      • Setting Up a Workflow
      • Common Workflows
        • Auto Annotation
        • Visual Text Recognition
        • Text Classification
    • Search, Sort, Filter and Save
      • Rank
      • Filter
      • Combine or Negate
      • Saved Searches
      • Visual Search
      • Text Search
    • Advanced Topics
      • Importing Data with CSV and TSV Files
  • Data Labeling Services
    • Scribe LabelForce
  • Product Updates
    • Upcoming API Changes
    • Changelog
      • Release 8.1
      • Release 8.0
      • Release 7.11
      • Release 7.10
      • Release 7.9
      • Release 7.8
      • Release 7.7
      • Release 7.6
      • Release 7.5
      • Release 7.4
      • Release 7.3
      • Release 7.2
      • Release 7.1
      • Release 7.0
      • Release 6.11
      • Release 6.10
      • Release 6.9
      • Release 6.8
      • Release 6.7
      • Release 6.6
      • Release 6.5
      • Release 6.4
      • Release 6.3
      • Release 6.2
      • Release 6.1
      • Release 6.0
      • Release 5.11
      • Release 5.10
  • Additional Resources
    • API Status
    • Clarifai Blog
    • Clarifai Help
    • Clarifai Community
Powered by GitBook
On this page
  • Supported Languages
  • Default Language
  • List language translations by concept ID
  • Get specific language translation for a concept
  • Add a language translation for a concept
  • Update a language translation for a concept

Was this helpful?

Edit on GitHub
  1. API Guide
  2. Creating and Managing Concepts

Languages

Multilingual support in Clarifai

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.

Language
Code

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.

List language translations by concept ID

import com.clarifai.grpc.api.*;
import com.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-instructions

MultiConceptResponse listConceptLanguagesResponse = stub.listConceptLanguages(
    ListConceptLanguagesRequest.newBuilder()
        .setConceptId("charlie")
        .build()
);

if (listConceptLanguagesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
    throw new RuntimeException("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-instructions

stub.ListConceptLanguages(
    {
      concept_id: "charlie"
    },
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("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-instructions

list_concept_languages_response = stub.ListConceptLanguages(
    service_pb2.ListConceptLanguagesRequest(
        concept_id="charlie"
    ),
    metadata=metadata
)

if list_concept_languages_response.status.code != status_code_pb2.SUCCESS:
    print("There was an error with your request!")
    print("\tCode: {}".format(list_concept_languages_response.outputs[0].status.code))
    print("\tDescription: {}".format(list_concept_languages_response.outputs[0].status.description))
    print("\tDetails: {}".format(list_concept_languages_response.outputs[0].status.details))
    raise Exception("List concept failed, status: " + list_concept_languages_response.status.description)
curl -X GET \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  https://api.clarifai.com/v2/concepts/{concept_id}/languages
const conceptId = '{CONCEPT_ID}'
const appId = '{YOUR_APP_ID}'

const requestOptions = {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
  }
};

fetch(`https://api.clarifai.com/v2/users/me/apps/${appId}/concepts/${conceptId}/languages`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Get specific language translation for a concept

To get a single language translation you have for a concept you can get by the language code and concept id.

import com.clarifai.grpc.api.*;
import com.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-instructions

MultiConceptResponse getConceptLanguageResponse = stub.getConceptLanguage(
    ListConceptLanguageRequest.newBuilder()
        .setConceptId("charlie")
        .setLanguage("ja")
        .build()
);

if (getConceptLanguageResponse.getStatus().getCode() != StatusCode.SUCCESS) {
    throw new RuntimeException("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-instructions

stub.GetConceptLanguage(
    {
      concept_id: "charlie",
      language: "ja"
    },
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("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-instructions

get_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:
    print("There was an error with your request!")
    print("\tCode: {}".format(get_concept_language_response.outputs[0].status.code))
    print("\tDescription: {}".format(get_concept_language_response.outputs[0].status.description))
    print("\tDetails: {}".format(get_concept_language_response.outputs[0].status.details))
    raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)
curl -X GET \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  https://api.clarifai.com/v2/concepts/{concept_id}/languages/{language}
const conceptId = '{CONCEPT_ID}'
const appId = '{YOUR_APP_ID}'
const language = '{LANGUAGE}'

const requestOptions = {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
  }
};

fetch(`https://api.clarifai.com/v2/users/me/apps/${appId}/concepts/${conceptId}/languages/${language}`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Add a language translation for a concept

To create a langauge translation for a concept you can POST that language translation.

import com.clarifai.grpc.api.*;
import com.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-instructions

MultiConceptResponse postConceptLanguageResponse = stub.postConceptLanguage(
    PostConceptLanguageRequest.newBuilder()
        .setConceptId("charlie")
        .addConceptLanguages(ConceptLanguage.newBuilder().setId("ja").setName("ボスコ"))
        .build()
);

if (postConceptLanguageResponse.getStatus().getCode() != StatusCode.SUCCESS) {
    throw new RuntimeException("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-instructions

stub.PostConceptLanguage(
    {
      concept_id: "charlie",
      concept_languages: [
        {
          id: "ja",
          name: "ボスコ"
        }
      ]
    },
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("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-instructions

get_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:
    print("There was an error with your request!")
    print("\tCode: {}".format(get_concept_language_response.outputs[0].status.code))
    print("\tDescription: {}".format(get_concept_language_response.outputs[0].status.description))
    print("\tDetails: {}".format(get_concept_language_response.outputs[0].status.details))
    raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)
curl -X GET \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  https://api.clarifai.com/v2/concepts/{concept_id}/languages/{language}
const conceptId = '{YOUR_CONCEPT_ID}'

const raw = JSON.stringify({
	"user_app_id": {
		"user_id": "{YOUR_USER_ID}",
		"app_id": "{YOUR_APP_ID}"
	},
  "concept_languages": [
    {
      "id": "ko",
      "name": "개"
    }
  ]
});

const requestOptions = {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
  },
  body: raw
};

fetch(`https://api.clarifai.com/v2/concepts/${conceptId}/languages`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Update a language translation for a concept

To update a langauge translation for a concept you can PATCH that language translation.

import com.clarifai.grpc.api.*;
import com.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-instructions

MultiConceptResponse patchConceptLanguageResponse = stub.patchConceptLanguage(
    PatchConceptLanguageRequest.newBuilder()
        .setAction("overwrite")
        .setConceptId("charlie")
        .addConceptLanguages(ConceptLanguage.newBuilder().setId("ja").setName("new name"))
        .build()
);

if (patchConceptLanguageResponse.getStatus().getCode() != StatusCode.SUCCESS) {
    throw new RuntimeException("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-instructions

stub.PatchConceptLanguage(
    {
      action: "overwrite",
      concept_id: "charlie",
      concept_languages: [
        {
          id: "ja",
          name: "new name"
        }
      ]
    },
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("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-instructions

get_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:
    print("There was an error with your request!")
    print("\tCode: {}".format(get_concept_language_response.outputs[0].status.code))
    print("\tDescription: {}".format(get_concept_language_response.outputs[0].status.description))
    print("\tDetails: {}".format(get_concept_language_response.outputs[0].status.details))
    raise Exception("Get concept failed, status: " + get_concept_language_response.status.description)
curl -X GET \
  -H "Authorization: Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  https://api.clarifai.com/v2/concepts/{concept_id}/languages/{language}
const conceptId = '{YOUR_CONCEPT_ID}'

const raw = JSON.stringify({
	"user_app_id": {
		"user_id": "{YOUR_USER_ID}",
		"app_id": "{YOUR_APP_ID}"
	},
  "concept_languages": [
    {
      "id": "ko",
      "name": "개"
    }
  ],
  "action": "overwrite"
});

var requestOptions = {
  method: 'PATCH',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
  },
  body: raw
};

fetch(`https://api.clarifai.com/v2/concepts/${conceptId}/languages`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
PreviousCreate, Get, UpdateNextSearch by Concept

Last updated 3 years ago

Was this helpful?

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

pagination
create new app