Ir para o conteúdo
For the complete DHIS2 documentation index, see llms.txt.

I18n

Localidades

DHIS2 supports translations both for the user interface and for database content.

IU locales

You can retrieve the available locales for the user interface through the following resource with a GET request. XML and JSON resource representations are supported.

/ api / 33 / locales / ui

Localidades de conteúdo de banco de dados

You can retrieve and create locales for the database content with GET and POST requests through the dbLocales resource. XML and JSON resource representations are supported. To POST data, there are two required parameters: country and language.

/api/locales/dbLocales?country=US&language=en

Traduções

DHIS2 allows for translations of database content. If a metadata is translatable, then it will have a translations property.

That means you can retrieve and update translations using metadata class resources such as api/dataElements, api/organisationUnits, api/dataSets, etc.

Obtenha traduções

You can get translations for a metadata object such as DataElement by sending a GET request to api/dataElements/{dataElementUID}

The response contains full details of the DataElement which also includes the translations property as below

{
  "id": "fbfJHSPpUQD",
  "href": "https://play.dhis2.org/dev/api/29/dataElements/fbfJHSPpUQD",
  "created": "2010-02-05T10:58:43.646",
  "name": "ANC 1st visit",
  "shortName": "ANC 1st visit",
  "translations": 
  [
    {
      "property": "SHORT_NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    },
    {
      "property": "NAME",
      "locale": "fr",
      "value": "Soin prénatal 1"
    },
    {
      "property": "NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    }
  ]
}
You can also get only the translations property of an object by sending a GET request to api/dataElements/{dataElementUID}/translations
{
  "translations": 
  [
    {
      "property": "SHORT_NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    },
    {
      "property": "NAME",
      "locale": "fr",
      "value": "Soin prénatal 1"
    },
    {
      "property": "NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    }
  ]
}

Create/Update translations

You can create translations by sending a PUT request with same JSON format to api/dataElements/{dataElementUID}/translations

{
  "translations": 
  [
    {
      "property": "SHORT_NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    },
    {
      "property": "NAME",
      "locale": "fr",
      "value": "Soin prénatal 1"
    },
    {
      "property": "DESCRIPTION",
      "locale": "fr",
      "value": "description in french"
    },
    {
      "property": "FORM_NAME",
      "locale": "fr",
      "value": "name in french"
    }
  ]
}

Alternatively, you can also just update the object with payload including the translations property.

Send PUT request to api/dataElements/{dataElementUID} with full object payload as below:

{
  "id": "fbfJHSPpUQD",
  "created": "2010-02-05T10:58:43.646",
  "name": "ANC 1st visit",
  "shortName": "ANC 1st visit",
  "translations": 
  [
    {
      "property": "SHORT_NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    },
    {
      "property": "NAME",
      "locale": "fr",
      "value": "Soin prénatal 1"
    },
    {
      "property": "NAME",
      "locale": "en_GB",
      "value": "ANC 1st visit"
    }
  ]
}

The status code will be 204 No Content if the data value was successfully saved or updated, or 409 Conflict if there was a validation error (e.g. more than one SHORT_NAME for the same locale).

The common properties which support translations are listed in the table below.

Property names
Property name Descrição
nome Object name
shortName Object short name
descrição Object description

As classes que oferecem suporte a traduções estão listadas na tabela abaixo.

Class names
Class name Descrição Other translatable Properties
DataElementCategoryOption Category option
DataElementCategory Category
DataElementCategoryCombo Category combination
Elemento de Dados Elemento de dados
DataElementGroup Data element group
DataElementGroupSet Data element group set
Indicador Indicador numeratorDescription, denominatorDescription
IndicatorType Indicator type
IndicatorGroup Indicator group
IndicatorGroupSet Indicator group set
OrganisationUnit Unidade organizacional
OrganisationUnitGroup Organisation unit group
OrganisationUnitGroupSet Organisation unit group set
Conjunto de Dados Conjunto de dados
Section Data set section
ValidationRule Validation rule instruction
ValidationRuleGroup Validation rule group
Programa Programa enrollmentDateLabel, incidentDateLabel
Estágio do Programa Estágio do programa executionDateLabel, dueDateLabel
Atributo de entidade rastreada Atributo de entidade rastreada
TrackedEntity Tracked entity
Tipo de Relacionamento Relationship type for tracked entity instances fromToName, toFromName
Conjunto de opções Option set
Opção Opção
Atributo Attribute for metadata
ProgramNotificationTemplate Program Notification template subjectTemplate, messageTemplate
ValidationNotificationTemplate Validation Notification template subjectTemplate, messageTemplate
DataSetNotificationTemplate DataSet Notification template subjectTemplate, messageTemplate
Visualization Visualization title, subtitle, rangeAxisLabel, baseLineLabel, targetLineLabel, domainAxisLabel
ProgramRuleAction Program Rule Actions content
Predictor Predictor Name, ShortName, Description, Generator Description
ValidationRule ValidationRule Name, Description, Instruction, Leftside expression, Rightside expression

Internacionalização

In order to retrieve key-value pairs for translated strings you can use the i18n resource.

/ api / 33 / i18n

The endpoint is located at /api/i18n and the request format is a simple array of the key-value pairs:

[
  "access_denied",
  "uploading_data_notification"
]

The request must be of type POST and use application/json as content-type. An example using curl, assuming the request data is saved as a file keys.json:

curl -d @keys.json "play.dhis2.org/demo/api/33/i18n" -X POST
  -H "Content-Type: application/json" -u admin:district

O resultado será assim:

{
  "access_denied": "Access denied",
  "uploading_data_notification": "Uploading locally stored data to the server"
}