Localization Service
The Localization Service enables callers to store and maintain localized data for use in software applications.
Access info
| Endpoint | https://l10n-api.socrate.io/graphql |
| Required access keys | Tenant-level service access key |
| Pricing | Check the available purchase options. |
| Notes | To call the service, the access key must be provided in the x-api-key header of the HTTP request. If you are using the GraphQL console, you can view the service’s documentation and schema only after entering an access key. Make sure that the scope of the key allows access to the queries and mutations that you require. For example, to grant the key access to all queries and mutations, the keys’s scope must be set to l10n-api:query:* l10n-api:mutation:*. |
How it works
The following terms are used in conjunction with this service:
- Locale. A locale is the combination of language and country (also known as “culture”) for which you would like to keep a separate translation. For example, en-US is a locale that identifies English language in the United States, de-DE identifies German language in Germany, and so on.
- Label. A label is a string in your application that can be translated. Graphical user interface elements such as buttons, input names, dialog boxes, and so on must all be identified by a label in order to be translatable.
- Translation. A translation is the text of a label adapted (translated) to a particular locale.
You can create, retrieve, update, and delete locales, labels, and label translations as demanded by the application’s requirements. For example, to localize your application in English and Romanian, you might want to proceed as follows:
- Create the en-US and ro-RO locales, by running the
createLocalemutation. For example, to create the ro-RO locale, run the following code:
mutation createLocale($input:CreateLocaleInput!) {
createLocale(input:$input) {
code
language
country
name
active
}
}
{
"input": {
"language": "ro",
"country": "RO"
}
}
- For each label in your application, run the
createLabelmutation and specify the label identifier (code) and its default text. The default text will be used in all contexts when no translation of that label is found. For example, you could create a label code btnCreateAccount with the following call:
mutation createLabel($input:CreateLabelInput!) {
createLabel(input:$input) {
code
text
description
}
}
{
"input": {
"code": "btnCreateAccount",
"text": "Create Account",
"description": "The button for creating new accounts."
}
}
- For each label in your application, run the
createLabelTranslationmutation, to have all your application’s labels translated. The end user behind this action is typically a translator. For example, to add a translation of the previously created button in Romanian, the mutation would look as follows:
mutation createLabelTranslation($input: CreateLabelTranslationInput!) {
createLabelTranslation(input:$input) {
code
localeCode
labelCode
text
}
}
{
"input": {
"localeCode": "ro-RO",
"labelCode": "btnCreateAccount",
"text": "Creează Cont"
}
}
After all labels have been translated, you can retrieve the translations available for a particular locale with the translations query. For example, the query in the code listing below retrieves all label translations in Romanian. You would typically run this query when the application starts (so as to populate the translated labels according to the currently selected locale), or when a user has changed the locale of the application from the graphical user interface.
query translations($filter:TranslationsFilter!) {
translations(filter:$filter) {
localeCode
labelCode
text
translated
}
}
{
"filter": {
"localeCode": "ro-RO"
}
}
The response looks similar to the one below:
{
"data": {
"translations": [
{
"localeCode": "ro-RO",
"labelCode": "btnCreateAccount",
"text": "Creează Cont",
"translated": true
}
]
}
}
The translated field in the response indicates whether a translation of the label has been found in the selected locale. Value true means the text field stores the label’s translation in the selected locale. Value false means that no translation was found, so the text field stores the default (not translated) text of the label.
Queries
labels
Returns the list of all labels, along with the translations available for each label.
Arguments
| Argument | Type | Description |
|---|---|---|
| filter | LabelsFilter |
Optional. Provides filtering options to the query. |
LabelsFilter input
| Attribute | Type | Description |
|---|---|---|
| code | String |
Optional. The identifier of the label. If this argument is supplied, only the label having this code will be returned in the result. |
| active | Boolean |
Optional. If supplied, only labels marked as active will be returned in the result. |
Result
Label type
| Attribute | Type | Description |
|---|---|---|
| code | String |
The unique identifier of the label in your application. |
| text | String |
The default human-readable text of the label in your application. |
| description | String |
The label’s description. |
| translations | [LabelTranslation] |
An array of LabelTranslation objects. Such objects store any translations available for the label. |
| active | Boolean |
A Boolean value which indicates whether the label is active or not. |
| createdAt | DateTime |
The date and time when the label was created. |
| updatedAt | DateTime |
The date and time when the label was last updated. |
LabelTranslation type
| Attribute | Type | Description |
|---|---|---|
| code | String |
The identifier of the label translation. This value is generated automatically, based on the localeCode and labelCode, and it takes the format localeCode-labelCode. |
| localCode | String |
The identifier of the locale. |
| labelCode | String |
The identifier of the label. |
| text | String |
The text of the translation. |
| createdAt | DateTime |
The date and time when the translation record was created. |
| updatedAt | DateTime |
The date and time when the translation record was last updated. |
locales
Returns a list of locales. For each locale, all the translations linked to it are also included.
Arguments
| Argument | Type | Description |
|---|---|---|
| filter | LocalesFilter |
Optional. Provides filtering options to the query. |
LocalesFilter input
| Attribute | Type | Description |
|---|---|---|
| code | String |
Optional. The identifier of the locale. If this argument is supplied, only the locale having this code will be returned in the result. |
| active | Boolean |
Optional. If supplied, only locales marked as active will be returned in the result. |
Result
Locale type
| Attribute | Type | Description |
|---|---|---|
| code | String |
The identifier of the locale. This value is generated automatically based on the combination of language and country selected when the locale was created. For example, the value could be ro-RO identifies the Romanian language in Romania. |
| language | Language |
Identifies the locale’s language. This is an enum of two-character language codes. |
| country | Country |
Identifies the locale’s country. This is an enum of two-character country codes. |
| name | String |
The long name of the locale, suitable for display in an application. |
| nativeName | String |
The long name of the locale, in the locale’s language. |
| active | Boolean |
A Boolean flag which indicates if the locale record is active or not. |
| labelTranslations | [LabelTranslation] |
This property contains all the translations linked this locale, as an array of LabelTranslation objects. |
| createdAt | DateTime |
The date and time when the locale record was created. |
| updatedAt | DateTime |
The date and time when the locale record was last updated. |
translations
Returns all translations available for the locale code supplied as argument. If a translation for this locale is not found, then the default label value is placed in the text field.
Arguments
| Argument | Type | Description |
|---|---|---|
| filter | TranslationsFilter! |
Mandatory. Supplies filtering options to the query. |
TranslationsFilter input
| Attribute | Type | Description |
|---|---|---|
| localeCode | String! |
Mandatory. The code of the locale for which translations should be retrieved. |
Result
The result in an array of Translation type objects.
Translation type
| Attribute | Type | Description |
|---|---|---|
| localeCode | String |
The locale code of the translation. |
| labelCode | String |
The label code of the translation. |
| text | String |
The text of the translation. |
| translated | Boolean |
A true value indicates that this is a translation. A false value means that a translation was not found so the default value of the label was returned. |
version
Returns the API version.
Mutations
createLabel
Creates a new label that identifies a translatable GUI element in your application.
Arguments
| Attribute | Type | Description |
|---|---|---|
| input | CreateLabelInput! |
Mandatory. Provides input data to the mutation. |
CreateLabelInput input
| Attribute | Type | Description |
|---|---|---|
| code | String! |
The unique identifier of the label in your application. For example btnCreateAccount could be the identifier of a “Create Account” button. |
| text | String |
The default text associated with this label. This text will be used if no translations of the label are found. For example, the text “Create Account” could be the default text for the btnCreateAccount button. |
| description | String |
A free text description that provides additional details about the label. |
Result
See the Label type.
createLabelTranslation
Adds a translation in a particular locale, to an existing label. Both the locale and the label must exist.
Arguments
| Attribute | Type | Description |
|---|---|---|
| input | CreateLabelTranslationInput! |
Mandatory. Provides input data to the mutation. |
CreateLabelTranslationInput input
| Attribute | Type | Description |
|---|---|---|
| localeCode | String! |
The identifier of the locale in which the label is being translated. |
| labelCode | String! |
The identifier of the label which is being translated. |
| text | String! |
The translated text. |
Result
See the LabelTranslation type.
createLocale
Creates a new locale.
Arguments
| Attribute | Type | Description |
|---|---|---|
| input | CreateLocaleInput! |
Mandatory. Provides input data to the mutation. |
CreateLocaleInput input
| Attribute | Type | Description |
|---|---|---|
| language | Language! |
Mandatory. Specifies the two-character language code of the locale. See Language codes for the list of valid values. |
| country | Country! |
Mandatory. Specifies the two-character country code of the locale. See Country codes for the list of valid values. |
| active | Boolean |
Optional flag which specifies if the locale is currently active. |
Result
See the Locale type.
deleteLabel
Deletes a label.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The unique identifier of the label that must be deleted. |
Result
See the Label type.
deleteLabelTranslation
Deletes the translation of a label.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The unique identifier of the label translation record. |
Result
See the LabelTranslation type.
deleteLocale
Deletes a locale.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The identifier of the locale that must be deleted. |
Result
See the Locale type.
updateLabel
Updates a label’s details.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The identifier of the label that must be updated. |
| input | UpdateLabelInput! |
Mandatory. Provides input data to the mutation. |
UpdateLabelInput input
| Attribute | Type | Description |
|---|---|---|
| text | String |
The default text associated with this label. This text will be used if no translations of the label are found. For example, the text “Create Account” could be the default text for the btnCreateAccount button. |
| description | String |
A free text description that provides additional details about the label. |
| active | Boolean |
A Boolean flag used to activate or deactivate the label. Set it to false to make the label inactive. |
Result
See the Label type.
updateLabelTranslation
Updates a label translation.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The identifier of the label translation that must be deleted. |
| input | UpdateLabelTranslationInput! |
Mandatory. Provides input data to the mutation. |
UpdateLabelTranslationInput input
| Attribute | Type | Description |
|---|---|---|
| text | String! |
The updated translation of the label . |
Result
See the LabelTranslation type.
updateLocale
Updates a locale. Note that the only locale property that can be updated is active.
Arguments
| Attribute | Type | Description |
|---|---|---|
| code | String! |
Mandatory. The identifier of the locale to be updated. |
| input | UpdateLocaleInput! |
Mandatory. Provides input data to the mutation. |
UpdateLocaleInput input
| Attribute | Type | Description |
|---|---|---|
| active | Boolean |
A Boolean flag used to activate or deactivate the locale. Set it to false to deactivate the locale. |
Result
See the Locale type.
Appendices
Language codes
| Code | Language |
|---|---|
| ab | Abkhazian |
| aa | Afar |
| af | Afrikaans |
| sq | Albanian |
| am | Amharic |
| ar | Arabic |
| hy | Armenian |
| as | Assamese |
| ay | Aymara |
| az | Azerbaijani |
| ba | Bashkir |
| eu | Basque |
| bn | Bengali |
| dz | Dzongkha |
| bh | Bihari languages |
| bi | Bislama |
| br | Breton |
| bg | Bulgarian |
| my | Burmese |
| be | Belarusian |
| km | Central Khmer |
| ca | Catalan; Valencian |
| zh | Chinese |
| co | Corsican |
| hr | Croatian |
| cs | Czech |
| da | Danish |
| nl | Dutch; Flemish |
| en | English |
| eo | Esperanto |
| et | Estonian |
| fo | Faroese |
| fa | Persian |
| fj | Fijian |
| fi | Finnish |
| fr | French |
| fy | Western Frisian |
| gl | Galician |
| gd | Gaelic; Scottish Gaelic |
| gv | Manx |
| ka | Georgian |
| de | German |
| el | Greek, Modern (1453-) |
| kl | Kalaallisut; Greenlandic |
| gn | Guarani |
| gu | Gujarati |
| ha | Hausa |
| he | Hebrew |
| hi | Hindi |
| hu | Hungarian |
| is | Icelandic |
| id | Indonesian |
| ia | Interlingua (IALA) |
| ie | Interlingue; Occidental |
| iu | Inuktitut |
| ik | Inupiaq |
| ga | Irish |
| it | Italian |
| ja | Japanese |
| kn | Kannada |
| ks | Kashmiri |
| kk | Kazakh |
| rw | Kinyarwanda |
| ky | Kirghiz; Kyrgyz |
| rn | Rundi |
| ko | Korean |
| ku | Kurdish |
| lo | Lao |
| la | Latin |
| lv | Latvian |
| li | Limburgan; Limburger; Limburgish |
| ln | Lingala |
| lt | Lithuanian |
| mk | Macedonian |
| mg | Malagasy |
| ms | Malay |
| ml | Malayalam |
| mt | Maltese |
| mi | Maori |
| mr | Marathi |
| mo | Moldavian; Moldovan |
| mn | Mongolian |
| na | Nauru |
| ne | Nepali |
| no | Norwegian |
| oc | Occitan (post 1500) |
| or | Oriya |
| om | Oromo |
| ps | Pushto; Pashto |
| pl | Polish |
| pt | Portuguese |
| pa | Panjabi; Punjabi |
| qu | Quechua |
| rm | Romansh |
| ro | Romanian |
| ru | Russian |
| sm | Samoan |
| sg | Sango |
| sa | Sanskrit |
| sr | Serbian |
| sh | Serbo-Croatian |
| st | Sotho, Southern |
| tn | Tswana |
| sn | Shona |
| sd | Sindhi |
| si | Sinhala; Sinhalese |
| ss | Swati |
| sk | Slovak |
| sl | Slovenian |
| so | Somali |
| es | Spanish |
| su | Sundanese |
| sw | Swahili |
| sv | Swedish |
| tl | Tagalog |
| tg | Tajik |
| ta | Tamil |
| tt | Tatar |
| te | Telugu |
| th | Thai |
| bo | Tibetan |
| ti | Tigrinya |
| to | Tonga (Tonga Islands) |
| ts | Tsonga |
| tr | Turkish |
| tk | Turkmen |
| tw | Twi |
| ug | Uighur; Uyghur |
| uk | Ukrainian |
| ur | Urdu |
| uz | Uzbek |
| vi | Vietnamese |
| vo | Volapük |
| cy | Welsh |
| wo | Wolof |
| xh | Xhosa |
| yi | Yiddish |
| yo | Yoruba |
| zu | Zulu |
Country codes
| Code | Country Name |
|---|---|
| AF | Afghanistan |
| AX | Åland Islands |
| AL | Albania |
| DZ | Algeria |
| AS | American Samoa |
| AD | Andorra |
| AO | Angola |
| AI | Anguilla |
| AQ | Antarctica |
| AG | Antigua and Barbuda |
| AR | Argentina |
| AM | Armenia |
| AW | Aruba |
| AU | Australia |
| AT | Austria |
| AZ | Azerbaijan |
| BS | Bahamas |
| BH | Bahrain |
| BD | Bangladesh |
| BB | Barbados |
| BY | Belarus |
| BE | Belgium |
| BZ | Belize |
| BJ | Benin |
| BM | Bermuda |
| BT | Bhutan |
| BO | Bolivia |
| BQ | Bonaire, Sint Eustatius and Saba |
| BA | Bosnia and Herzegovina |
| BW | Botswana |
| BV | Bouvet Island |
| BR | Brazil |
| IO | British Indian Ocean Territory |
| BN | Brunei Darussalam |
| BG | Bulgaria |
| BF | Burkina Faso |
| BI | Burundi |
| CV | Cabo Verde |
| KH | Cambodia |
| CM | Cameroon |
| CA | Canada |
| KY | Cayman Islands |
| CF | Central African Republic |
| TD | Chad |
| CL | Chile |
| CN | China |
| CX | Christmas Island |
| CC | Cocos Islands |
| CO | Colombia |
| KM | Comoros |
| CG | Congo |
| CD | Democratic Republic of the Congo |
| CK | Cook Islands |
| CR | Costa Rica |
| CI | Côte d’Ivoire (Ivory Coast) |
| HR | Croatia |
| CU | Cuba |
| CW | Curaçao |
| CY | Cyprus |
| CZ | Czech Republic |
| DK | Denmark |
| DJ | Djibouti |
| DM | Dominica |
| DO | Dominican Republic |
| EC | Ecuador |
| EG | Egypt |
| SV | El Salvador |
| GQ | Equatorial Guinea |
| ER | Eritrea |
| EE | Estonia |
| SZ | Eswatini (Swaziland) |
| ET | Ethiopia |
| FK | Falkland Islands |
| FO | Faroe Islands |
| FJ | Fiji |
| FI | Finland |
| FR | France |
| GF | French Guiana |
| PF | French Polynesia |
| TF | French Southern Territories |
| GA | Gabon |
| GM | Gambia |
| GE | Georgia |
| DE | Germany |
| GH | Ghana |
| GI | Gibraltar |
| GR | Greece |
| GL | Greenland |
| GD | Grenada |
| GP | Guadeloupe |
| GU | Guam |
| GT | Guatemala |
| GG | Guernsey |
| GN | Guinea |
| GW | Guinea-Bissau |
| GY | Guyana |
| HT | Haiti |
| HM | Heard Island and McDonald Islands |
| VA | Holy See (Vatican City) |
| HN | Honduras |
| HK | Hong Kong |
| HU | Hungary |
| IS | Iceland |
| IN | India |
| ID | Indonesia |
| IR | Iran |
| IQ | Iraq |
| IE | Ireland |
| IM | Isle of Man |
| IL | Israel |
| IT | Italy |
| JM | Jamaica |
| JP | Japan |
| JE | Jersey |
| JO | Jordan |
| KZ | Kazakhstan |
| KE | Kenya |
| KI | Kiribati |
| KP | North Korea |
| KR | South Korea |
| KW | Kuwait |
| KG | Kyrgyzstan |
| LA | Laos |
| LV | Latvia |
| LB | Lebanon |
| LS | Lesotho |
| LR | Liberia |
| LY | Libya |
| LI | Liechtenstein |
| LT | Lithuania |
| LU | Luxembourg |
| MO | Macau |
| MG | Madagascar |
| MW | Malawi |
| MY | Malaysia |
| MV | Maldives |
| ML | Mali |
| MT | Malta |
| MH | Marshall Islands |
| MQ | Martinique |
| MR | Mauritania |
| MU | Mauritius |
| YT | Mayotte |
| MX | Mexico |
| FM | Micronesia |
| MD | Moldova |
| MC | Monaco |
| MN | Mongolia |
| ME | Montenegro |
| MS | Montserrat |
| MA | Morocco |
| MZ | Mozambique |
| MM | Myanmar (Burma) |
| NA | Namibia |
| NR | Nauru |
| NP | Nepal |
| NL | Netherlands |
| NC | New Caledonia |
| NZ | New Zealand |
| NI | Nicaragua |
| NE | Niger |
| NG | Nigeria |
| NU | Niue |
| NF | Norfolk Island |
| MK | North Macedonia |
| MP | Northern Mariana Islands |
| NO | Norway |
| OM | Oman |
| PK | Pakistan |
| PW | Palau |
| PS | Palestine |
| PA | Panama |
| PG | Papua New Guinea |
| PY | Paraguay |
| PE | Peru |
| PH | Philippines |
| PN | Pitcairn |
| PL | Poland |
| PT | Portugal |
| PR | Puerto Rico |
| QA | Qatar |
| RE | Réunion |
| RO | Romania |
| RU | Russia |
| RW | Rwanda |
| BL | Saint Barthélemy |
| SH | Saint Helena, Ascension and Tristan da Cunha |
| KN | Saint Kitts and Nevis |
| LC | Saint Lucia |
| MF | Saint Martin |
| PM | Saint Pierre and Miquelon |
| VC | Saint Vincent and the Grenadines |
| WS | Samoa |
| SM | San Marino |
| ST | São Tomé and Príncipe |
| SA | Saudi Arabia |
| SN | Senegal |
| RS | Serbia |
| SC | Seychelles |
| SL | Sierra Leone |
| SG | Singapore |
| SX | Sint Maarten |
| SK | Slovakia |
| SI | Slovenia |
| SB | Solomon Islands |
| SO | Somalia |
| ZA | South Africa |
| GS | South Georgia and the South Sandwich Islands |
| SS | South Sudan |
| ES | Spain |
| LK | Sri Lanka |
| SD | Sudan |
| SR | Suriname |
| SJ | Svalbard and Jan Mayen |
| SE | Sweden |
| CH | Switzerland |
| SY | Syria |
| TW | Taiwan |
| TJ | Tajikistan |
| TZ | Tanzania |
| TH | Thailand |
| TL | Timor-Leste (East Timor) |
| TG | Togo |
| TK | Tokelau |
| TO | Tonga |
| TT | Trinidad and Tobago |
| TN | Tunisia |
| TR | Turkey |
| TM | Turkmenistan |
| TC | Turks and Caicos Islands |
| TV | Tuvalu |
| UG | Uganda |
| UA | Ukraine |
| AE | United Arab Emirates |
| GB | United Kingdom |
| US | United States |
| UM | United States Minor Outlying Islands |
| UY | Uruguay |
| UZ | Uzbekistan |
| VU | Vanuatu |
| VE | Venezuela |
| VN | Vietnam |
| VG | British Virgin Islands |
| VI | U.S. Virgin Islands |
| WF | Wallis and Futuna |
| EH | Western Sahara |
| YE | Yemen |
| ZM | Zambia |
| ZW | Zimbabwe |