onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
2 stars 1 forks source link

Localization Support - Merging #70

Closed lincmba closed 11 months ago

lincmba commented 11 months ago

Follows https://github.com/onaio/fhir-tooling/issues/10 and https://github.com/onaio/fhir-tooling/issues/62 and https://github.com/onaio/fhir-tooling/issues/62

Overview

This issue is part of a broader effort to support the localization of FHIR content resources. It focuses on the third phase of this, which involves merging the translated content back into the original FHIR resources. The previous phases (content extraction and configs extraction) have prepared the content for translation. This phase addresses the merging of translated content back into the FHIR resources, ensuring that the resources contain the necessary language extensions.

Implementation

The merging phase involves taking the translated content (typically stored in properties files) and applying it to the original FHIR resources. The process should be efficient and automated to reduce manual intervention.

Key implementation steps include:

  1. Parsing the translated properties file: The tool should parse the properties file containing the translated content and language-specific keys.
  2. Identifying the field to be translated: Determine the field to which the translations should be applied. This can be done by hashing the relevant fields and getting the matching translation keys from the properties files
  3. Applying language extensions: Add translation extensions to all occurrences of untranslated text in the FHIR resources. These extensions include language codes and translated content.

Sample Command

A sample command for the merging phase might look like this:

fct translate -m merge -l fr -rf /some/path/to/Questionnaire.json -tf /some/path/<translated locale file>.properties

Acceptance Criteria

Original file

{
  "text": "this is a text",
  "display": "this is a display"
}

Translated File

{
  "text": "this is a text",
  "_text": {
    "extension": [
      {
        "extension": [
          {
            "url": "lang",
            "valueCode": "vi-VN"
          },
          {
            "url": "content",
            "valueString": "this is a translated text"
          }
        ],
        "url": "http://hl7.org/fhir/StructureDefinition/translation"
      }
    ],
  "display": "this is a display",
    "_display": {
      "extension": [
        {
          "extension": [
            {
              "url": "lang",
              "valueCode": "vi-VN"
            },
            {
              "url": "content",
              "valueString": "this is a translated display"
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/translation"
        }
      ]
}

Enhancements

ndegwamartin commented 11 months ago

We can add that on subsequent runs, it should overwrite any pre-existing translations on the resource incase a translation was edited.