Importing Translations with csv files

Dear DHIS2 users,

We are looking for a way to mass import translation files in DHIS2 for various objects (Data element name, Options, Option sets, Program Stage Section Names, etc.). We used to do that in earlier versions, but in later ones, it was not supported. Now, this feature is introduced again in version 2.29.
Our issue is that we cannot get a successful CSV import in our 2.29 DHIS2. The import files are based on the developer’s guide for the respected version and used to work fine in earlier versions. In all cases, we get no error, but just the “0” imported.

Do you have any experience in importing translations files (via CSV) in 2.29 or later versions?

An alternative can be a .json file, but our users will definitely prefer the .csv approach.

Thanks in advance.
Kristiyan Panayotov

1 Like

@stephocay @julhas @megankill @Eric_Munyambabazi @jomutsani Do you know any Translation import experts we can connect with? THANK YOU!

Hi Sara,

No one specific for the importation of translations but if the translations are readily available, it can be easily managed via API as described here

Thanks

@stephocay,

Thanks for your response! How can we quickly build the json file out of an excel with translations?
We have nearly 400 data elements (names, short names, form name, description) + option sets + Stage sections…

Georgi

Hi @Georgi,

You can use this online tool that will convert your metadata from csv to json

https://www.convertcsv.com/csv-to-json.htm

Save your excel as csv and upload the csv file. You will then need to update the json file to define the DHIS2 objects like dataElements.

Regards

Hi @stephocay,

Thanks, yes I found this converter. Works nice.
Can you give me a quick guidance on how to post the json trhought the API?
When I used this command: https://dev.piirs.care.org/POST%20/api/26/translations I get an Error message

Do I need to enable some permissions or am I posting the command wrong?

Georgi

Ig @Georgi Chakarov ,

If you have formatted the JSON file correctly, you can just import using the DHIS2 import export app

regards

@stephocay,

I have tried multiple versions of json format, but none worked through the import export app.
I aslo tried using postman to POST translations, as per the instructions in the guide - still unsuccessful. Any guidance that you can send over? I am also available for a chat any time this weekend. We are a bit in a rush.

Georgi

Hi Georgi, may I have a look at the format of the json file you are trying to posts. As I indicated earlier, the translations are now part of the metadata objects e.g. data elements etc. so to import them, you will be required to import the objects with the objects together.

{
“dataElements”: [
{
“code”: “033B-AP01”,
“lastUpdated”: “2020-03-11T13:04:53.877”,
“id”: “NeKm5EvaJYf”,
“href”: “https://htm-repo.dev.hispuganda.org/api/dataElements/NeKm5EvaJYf”,
“created”: “2020-03-11T13:04:53.817”,
“name”: “033B-AP01. OPD New”,
“shortName”: “033B-AP01. OPD New”,
“aggregationType”: “SUM”,
“domainType”: “AGGREGATE”,
“displayName”: “033B-AP01. OPD New”,
“publicAccess”: “rw------”,
“description”: “033B-AP01. OPD New”,
“displayShortName”: “033B-AP01. OPD New”,
“externalAccess”: false,
“valueType”: “INTEGER_ZERO_OR_POSITIVE”,
“formName”: “033B-AP01. OPD New”,
“displayDescription”: “033B-AP01. OPD New”,
“dimensionItem”: “NeKm5EvaJYf”,
“displayFormName”: “033B-AP01. OPD New”,
“zeroIsSignificant”: true,
“favorite”: false,
“optionSetValue”: false,
“dimensionItemType”: “DATA_ELEMENT”,
“access”: {
“read”: true,
“update”: true,
“externalize”: true,
“delete”: true,
“write”: true,
“manage”: true
},
“categoryCombo”: {
“id”: “bjDvmb4bfuf”
},
“lastUpdatedBy”: {
“id”: “M5zQapPyTZI”
},
“user”: {
“id”: “M5zQapPyTZI”
},
“favorites”: [],
“dataSetElements”: [
{
“dataElement”: {
“id”: “NeKm5EvaJYf”
},
“dataSet”: {
“id”: “S84cwAtAf5z”
}
}
],
"translations": [],
“userGroupAccesses”: [],
“dataElementGroups”: [],
“attributeValues”: [],
“userAccesses”: [],
“legendSets”: [],
“aggregationLevels”: []
}
]
}

Notice the highlighted section of translations is where where you put the translations

See Below:

{
“dataElements”: [
{
“code”: “033B-AP01”,
“lastUpdated”: “2020-03-11T13:04:53.877”,
“id”: “NeKm5EvaJYf”,
“href”: “https://htm-repo.dev.hispuganda.org/api/dataElements/NeKm5EvaJYf”,
“created”: “2020-03-11T13:04:53.817”,
“name”: “033B-AP01. OPD New”,
“shortName”: “033B-AP01. OPD New”,
“aggregationType”: “SUM”,
“domainType”: “AGGREGATE”,
“displayName”: “033B-AP01. OPD New”,
“publicAccess”: “rw------”,
“description”: “033B-AP01. OPD New”,
“displayShortName”: “033B-AP01. OPD New”,
“externalAccess”: false,
“valueType”: “INTEGER_ZERO_OR_POSITIVE”,
“formName”: “033B-AP01. OPD New”,
“displayDescription”: “033B-AP01. OPD New”,
“dimensionItem”: “NeKm5EvaJYf”,
“displayFormName”: “033B-AP01. OPD New”,
“zeroIsSignificant”: true,
“favorite”: false,
“optionSetValue”: false,
“dimensionItemType”: “DATA_ELEMENT”,
“access”: {
“read”: true,
“update”: true,
“externalize”: true,
“delete”: true,
“write”: true,
“manage”: true
},
“categoryCombo”: {
“id”: “bjDvmb4bfuf”
},
“lastUpdatedBy”: {
“id”: “M5zQapPyTZI”
},
“user”: {
“id”: “M5zQapPyTZI”
},
“favorites”: [],
“dataSetElements”: [
{
“dataElement”: {
“id”: “NeKm5EvaJYf”
},
“dataSet”: {
“id”: “S84cwAtAf5z”
}
}
],
"translations": [
{
“property”: “SHORT_NAME”,
“locale”: “fr”,
“value”: “OPD Nouveau”
},
{
“property”: “NAME”,
“locale”: “fr”,
“value”: “033B-AP01. OPD Nouveau”
}
],
“userGroupAccesses”: [],
“dataElementGroups”: [],
“attributeValues”: [],
“userAccesses”: [],
“legendSets”: [],
“aggregationLevels”: []
}
]
}

Hi Stephen,

Thanks for the response! I have been trying to import the format below and some variations of it, like removing the square brackets, etc. So you are saying that I need to create a json file with all the details of the data elements and import back? I will give it a shot.

[
{
“objectId”: “F10ZOcwHvTv”,
“className”: “dataElement”,
“locale”: “es”,
“property”: “name”,
“value”: “Otra modalidad”
}
]

Hi again Stephen,

So this is what I did:

  1. I downloaded metadata in json for my Data elements
  2. Isolated one data element and populated the values in the translation brackets
  3. Imported back
  4. The import result gives me that 1 item has been updated, but when I go to the data element itself there is no translation value.

See below the json format itself.

{
“dataElements”: [
{
“code”: “hum_edu_dir”,
“lastUpdated”: “2020-03-17T09:56:07.433”,
“id”: “iND9UwEytPL”,
“created”: “2020-03-17T09:56:07.338”,
“name”: “Humanitarian - Direct participants reached in the FY (Education)”,
“shortName”: “Hum-Direct participants reached (Education)”,
“aggregationType”: “SUM”,
“domainType”: “TRACKER”,
“publicAccess”: “rw------”,
“description”: “”,
“valueType”: “INTEGER_ZERO_OR_POSITIVE”,
“formName”: "Education: Direct participants \nreached in the FY ",
“zeroIsSignificant”: false,
“categoryCombo”: {
“id”: “bjDvmb4bfuf”
},
“lastUpdatedBy”: {
“id”: “zkApVOpQQNd”
},
“user”: {
“id”: “zkApVOpQQNd”
},
“translations”: [
{
“property”: “NAME”,
“locale”: “es”,
“value”: “Desarrollo - Participantes directos alcanzados en el año fiscal (Educación)”
},
{
“property”: “SHORT_NAME”,
“locale”: “es”,
“value”: “Des-Partic directos Educación”
},
{
“property”: “FORM_NAME”,
“locale”: “es”,
“value”: “Educación: Participantes directos alcanzados en el año fiscal”
},
{
“property”: “”,
“locale”: “”,
“value”: “”
},
{
“property”: “”,
“locale”: “”,
“value”: “”
},
{
“property”: “”,
“locale”: “”,
“value”: “”
},
{
“property”: “”,
“locale”: “”,
“value”: “”
},
{
“property”: “”,
“locale”: “”,
“value”: “”
}
],
“optionSet”: {
“id”: “”
}
}
]
}