Custom form translation

Hi all,
I’m looking at ways to support translation in a custom form (aggregate). I would like to be able to use the "built in" translation of data elements if possible, using IDs when designing the form and having a javascript function triggered by "dhis2.de.event.formReady" to put in the correct translations. I was thinking the formName, displayName or similar would be available in the dhis2 object, but I’m having difficult figuring out where.

Can any of the dev advice on where to read the translated names/formNames, if possible?

Does anyone else have any experience with something like this?

Thinking of it now, this might even be an idea for a general feature: just like you can add the data entry fields, totals and indicators when designing custom forms, there could be an option to add "name" label that would display the name/form name of an element, with translation when applicable.

Regards
Olav

I think HISP VN has done something along these lines

···

On Feb 15, 2016 10:57 AM, “Olav Poppe” olav.poppe@me.com wrote:

Hi all,

I’m looking at ways to support translation in a custom form (aggregate). I would like to be able to use the “built in” translation of data elements if possible, using IDs when designing the form and having a javascript function triggered by “dhis2.de.event.formReady” to put in the correct translations. I was thinking the formName, displayName or similar would be available in the dhis2 object, but I’m having difficult figuring out where.

Can any of the dev advice on where to read the translated names/formNames, if possible?

Does anyone else have any experience with something like this?

Thinking of it now, this might even be an idea for a general feature: just like you can add the data entry fields, totals and indicators when designing custom forms, there could be an option to add “name” label that would display the name/form name of an element, with translation when applicable.

Regards

Olav


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Hi Olav

We have done this in Lao but not using the built-in names. I can ask HISP VN if code can be shared if you’d like?

Nick

···

On Tue, Feb 16, 2016 at 10:26 PM, Knut Staring knutst@gmail.com wrote:

I think HISP VN has done something along these lines

On Feb 15, 2016 10:57 AM, “Olav Poppe” olav.poppe@me.com wrote:

Hi all,

I’m looking at ways to support translation in a custom form (aggregate). I would like to be able to use the “built in” translation of data elements if possible, using IDs when designing the form and having a javascript function triggered by “dhis2.de.event.formReady” to put in the correct translations. I was thinking the formName, displayName or similar would be available in the dhis2 object, but I’m having difficult figuring out where.

Can any of the dev advice on where to read the translated names/formNames, if possible?

Does anyone else have any experience with something like this?

Thinking of it now, this might even be an idea for a general feature: just like you can add the data entry fields, totals and indicators when designing custom forms, there could be an option to add “name” label that would display the name/form name of an element, with translation when applicable.

Regards

Olav


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Shurajit Dutta
Health Information Consultant

Hi Olav,

···

On Mon, Feb 15, 2016 at 4:57 AM, Olav Poppe olav.poppe@me.com wrote:

Hi all,

I’m looking at ways to support translation in a custom form (aggregate). I would like to be able to use the “built in” translation of data elements if possible, using IDs when designing the form and having a javascript function triggered by “dhis2.de.event.formReady” to put in the correct translations. I was thinking the formName, displayName or similar would be available in the dhis2 object, but I’m having difficult figuring out where.

Can any of the dev advice on where to read the translated names/formNames, if possible?

Does anyone else have any experience with something like this?

Thinking of it now, this might even be an idea for a general feature: just like you can add the data entry fields, totals and indicators when designing custom forms, there could be an option to add “name” label that would display the name/form name of an element, with translation when applicable.

that sounds like a great idea. Something like a variable, e.g. ${.name} , which can be substituted based on the selected locale of the current user.

Feel free to write a blueprint.

You can load this from the API, which in 2.22 lets you use the “displayName” property of objects which are translated to the appropriate language.

So something like this:

https://play.dhis2.org/demo/api/dataSets/BfMAe6Itzgt.json?fields=dataElements[id,displayName]

will give you the translated name of all data elements in a data set.

You could potentially load this once when data entry page is loaded from within a custom form, and then substitute labels yourself.

Overview of callback events:

http://dhis2.github.io/dhis2-docs/master/en/user/html/ch06s02.html#d5e1369

regards,

Lars

Regards

Olav


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Thanks, Lars - blueprint here: https://blueprints.launchpad.net/dhis2/+spec/translatable-de-names-custom-forms

My initial thinking was to see if the translated names were stored/cached somewhere and avoid API-calls for the sake of offline support (e.g. it would work even if the user went offline before a specific form was opened), but in most cases it should not be a problem.

Regards

Olav

···

On Mon, Feb 15, 2016 at 4:57 AM, Olav Poppe olav.poppe@me.com wrote:

Hi all,

I’m looking at ways to support translation in a custom form (aggregate). I would like to be able to use the “built in” translation of data elements if possible, using IDs when designing the form and having a javascript function triggered by “dhis2.de.event.formReady” to put in the correct translations. I was thinking the formName, displayName or similar would be available in the dhis2 object, but I’m having difficult figuring out where.

Can any of the dev advice on where to read the translated names/formNames, if possible?

Does anyone else have any experience with something like this?

Thinking of it now, this might even be an idea for a general feature: just like you can add the data entry fields, totals and indicators when designing custom forms, there could be an option to add “name” label that would display the name/form name of an element, with translation when applicable.

that sounds like a great idea. Something like a variable, e.g. ${.name} , which can be substituted based on the selected locale of the current user.

Feel free to write a blueprint.

You can load this from the API, which in 2.22 lets you use the “displayName” property of objects which are translated to the appropriate language.

So something like this:

https://play.dhis2.org/demo/api/dataSets/BfMAe6Itzgt.json?fields=dataElements[id,displayName]

will give you the translated name of all data elements in a data set.

You could potentially load this once when data entry page is loaded from within a custom form, and then substitute labels yourself.

Overview of callback events:

http://dhis2.github.io/dhis2-docs/master/en/user/html/ch06s02.html#d5e1369

regards,

Lars

Regards

Olav


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

2 posts were split to a new topic: Translation for custom forms

6 year old topic. For an update please see Jira issue: [DHIS2-12081] - Jira ​(mentioned in post:Translation for custom forms