Hello all,
I figured out the import of translations for all objects through the Import/Export app, using a json format. Here are the steps for the those interested:
-
Translate manually the details of your desired object (data element, option, TE attribute, etc.). Then export the object in json format through Metadata export of the Import/Export app. This will give you the proper json format of the object details, along with the translation code. Save this original metadata export for later.
-
Use a json to csv converter to convert into a more user friendly format and follow the example of you translated object in step 1 to populate the translation properties, locale and values for the rest of your objects. This is a good converter to use: https://www.convertcsv.com/json-to-csv.htm
-
Convert your csv/excel back to json using this converter https://www.convertcsv.com/csv-to-json.htm
-
Observe the differences between the converted file in Step 3 and your original metadata export in Step 1, as the csv to json converter will not produce the exact json format needed for DHIS2 import. Some of the things to look for:
a) Make sure that in your work csv file, there are no empty fields in the middle of your data. For example, if there are empty descriptions of data elements just replace them with “N/A” or you will get an error at importing your json.
b) When you export your original metadata in Step 1, it will begin with this:
{“system”:{“id”:“49184e0e-2471-4265-a9d4-95c3f4f75eeb”,“rev”:“ae5b691”,“version”:“2.29”,“date”:“2020-03-30T09:26:55.738”},“dataElements”:[
This code will be missing in the converted json file in Step 3, so add it in the beginning AND add this bracket } at the end of the file to complete it.
c) There might be some fileds at the end of your csv that do not have any values, like userGroupAccesses, dataElementGroups, attributeValues if you work with data elements metadata. In the converted json file in Step 3, these empty fields will be coded as “userGroupAccesses”: “”. Replace the “” (space and double quotes) with [].
d) Generally, if you get errors at import observe the original metadata you exported in Step 1 and the one you produced in Step 3 and try to find any major differences, such as missing metadata object or format differences, fix them and try importing back.
Below are example of json formats for different objects that work for translations in two languages:
1. Data elements
{“system”:{“id”:“49184e0e-2471-4265-a9d4-95c3f4f75eeb”,“rev”:“ae5b691”,“version”:“2.29”,“date”:“2020-03-30T09:26:55.738”},“dataElements”:[
{
“code”: “geo_lev_01”,
“lastUpdated”: “2020-03-29T08:18:24.700”,
“id”: “xwhEtKWb87i”,
“created”: “2020-03-17T09:56:07.337”,
“name”: “1st level: states, cities, regions, other”,
“shortName”: “1st level: states, cities, regions, other”,
“aggregationType”: “NONE”,
“domainType”: “TRACKER”,
“publicAccess”: “rw------”,
“description”: “N/A”,
“valueType”: “LONG_TEXT”,
“formName”: “1st level: states, cities, regions, other”,
“zeroIsSignificant”: false,
“categoryCombo”: {
“id”: “bjDvmb4bfuf”
},
“lastUpdatedBy”: {
“id”: “zkApVOpQQNd”
},
“user”: {
“id”: “zkApVOpQQNd”
},
“translations”: [
{
“property”: “NAME”,
“locale”: “es”,
“value”: “1er nivel: estados, ciudades, regiones, otros”
},
{
“property”: “SHORT_NAME”,
“locale”: “es”,
“value”: “1er nivel: estados, ciudades, regiones, otros”
},
{
“property”: “FORM_NAME”,
“locale”: “es”,
“value”: “1er nivel: estados, ciudades, regiones, otros”
},
{
“property”: “DESCRIPTION”,
“locale”: “es”,
“value”: “N/A”
},
{
“property”: “NAME”,
“locale”: “fr”,
“value”: “1er niveau : États, villes, régions, autres”
},
{
“property”: “SHORT_NAME”,
“locale”: “fr”,
“value”: “1er niveau : États, villes, régions, autres”
},
{
“property”: “FORM_NAME”,
“locale”: “fr”,
“value”: “1er niveau : États, villes, régions, autres”
},
{
“property”: “DESCRIPTION”,
“locale”: “fr”,
“value”: “N/A”
}
],
“optionSet”: {
“id”:[]
},
“userGroupAccesses”:[],
“dataElementGroups”:[],
“attributeValues”:[],
“userAccesses”:[],
“legendSets”:[],
“aggregationLevels”:[]
}
]
}
2. Program Stage sections
{“system”:{“id”:“49184e0e-2471-4265-a9d4-95c3f4f75eeb”,“rev”:“ae5b691”,“version”:“2.29”,“date”:“2020-03-30T11:03:14.219”},“programStageSections”:[
{
“created”: “2020-02-11T11:18:01.009”,
“lastUpdated”: “2020-03-30T06:41:26.317”,
“name”: “ACTUAL TOTAL PARTICIPANTS (for projects that have ended in this FY)”,
“id”: “uZOBUbwlXgZ”,
“sortOrder”: 19,
“lastUpdatedBy”: {
“id”: “zkApVOpQQNd”
},
“programStage”: {
“id”: “k5vUtGga5yY”
},
“programIndicators”:[],
“translations”: [
{
“property”: “NAME”,
“locale”: “es”,
“value”: "PARTICIPANTES TOTALES REALES (si el proyecto ha terminado este AF) "
},
{
“property”: “NAME”,
“locale”: “fr”,
“value”: “TOTAL RÉEL DES PARTICIPANTS (si le projet a été finalisé au cours de cet exercice fiscal)”
}
],
“dataElements”: [
{
“id”: “qkw0nEMKMJl”
},
{
“id”: “dGAkmmLOvBG”
},
{
“id”: “jFosVs0cGOD”
},
{
“id”: “YQEUQvFmCQj”
},
{
“id”: “RSxkUpFT4GA”
},
{
“id”: “QTyBcOJK9es”
},
{
“id”: “YGT6bYHn7jW”
},
{
“id”:[]
},
{
“id”:[]
},
{
“id”:[]
},
{
“id”:[]
},
{
“id”:[]
},
{
“id”:[]
}
]
}
]
}
3. Options
{“system”:{“id”:“49184e0e-2471-4265-a9d4-95c3f4f75eeb”,“rev”:“ae5b691”,“version”:“2.29”,“date”:“2020-03-31T09:18:34.780”},“options”:[
{
“code”: “0. Harmful”,
“created”: “2020-03-31T09:16:48.469”,
“lastUpdated”: “2020-03-31T09:16:48.512”,
“name”: “0. Harmful”,
“id”: “hVmW0Q2FjOn”,
“sortOrder”: 1,
“optionSet”: {
“id”: “kTiTAh4Zq3D”
},
“attributeValues”:[],
“translations”: [
{
“property”: “NAME”,
“locale”: “es”,
“value”: “0. Nocivo”
},
{
“property”: “NAME”,
“locale”: “fr”,
“value”: “0. Nocif”
}
]
}
]
}
4. Tracked entity attributes
{“system”:{“id”:“49184e0e-2471-4265-a9d4-95c3f4f75eeb”,“rev”:“ae5b691”,“version”:“2.29”,“date”:“2020-03-31T10:53:39.626”},“trackedEntityAttributes”:[
{
“code”: “Contact 1 Email”,
“lastUpdated”: “2020-02-10T17:06:33.958”,
“id”: “RrGR4WnEE6X”,
“created”: “2020-02-10T17:06:33.958”,
“name”: “Contact #1 Email”,
“shortName”: “Contact 1 Email”,
“aggregationType”: “COUNT”,
“programScope”: false,
“displayInListNoProgram”: false,
“publicAccess”: “rw------”,
“generated”: false,
“displayOnVisitSchedule”: false,
“valueType”: “EMAIL”,
“orgunitScope”: false,
“confidential”: false,
“unique”: false,
“inherit”: false,
“lastUpdatedBy”: {
“id”: “KHsE5DD09bF”
},
“user”: {
“id”: “KHsE5DD09bF”
},
“description”: “N/A”,
“translations”: [
{
“property”: “NAME”,
“locale”: “es”,
“value”: “Contacto #2 Cargo/Rol”
},
{
“property”: “SHORT_NAME”,
“locale”: “es”,
“value”: “Contacto #2 Cargo/Rol”
},
{
“property”: “NAME”,
“locale”: “fr”,
“value”: “Coordonnées #2 Position”
},
{
“property”: “SHORT_NAME”,
“locale”: “fr”,
“value”: “Coordonnées #2 Position”
}
],
“userGroupAccesses”:[],
“attributeValues”:[],
“userAccesses”:[],
“legendSets”:[]
}
]
}
@stephocay @Knut_Staring @Markus share and use as you find appropriate.