hielkema / postco

Postcoordination tooling Terminologiecentrum
MIT License
1 stars 0 forks source link

Support multiple languages in parser service #38

Closed basharmsen closed 3 years ago

basharmsen commented 3 years ago

The parser service should support multiple languages for

basharmsen commented 3 years ago

The format of the template files is changed for this issue. In the template files the values of the following fields

shall now be specified using the following format:

<???>
  <txt lang="???">???</txt>
  <txt lang="???">???</txt>
<???>

For Example:

<title>
  <txt lang="nl">Complicatie van lichaamsstructuur</txt>
  <txt lang="en">Complication of body structure</txt>
</title>

I've added a defaultLang-attribute to the <template>-elements. The value of this attribute is used as the default language when a template is not available in the requested language. The title of a template and the titles of the items shall have a non-empty txt-child for the default language to ensure that these fields are available for the default language.

I've added an url parameter lang to the operations /Templates an Templates/TemplateId to specify the preferred language. For each template in the results the service checks if the template is available for the preferred language. When a template is not available for the preferred language then its default language is used.

The results of the template service now also include the fields currentLanguage and supportedLanguages. currentLanguage is the language that is used for the template in the current response (as described above this can be different from the requested language). A language is included in the array supportedLanguages when all required fields (the title of the template and the title for each item) are specified for this language.

The tags are now defined in a central file tags.xml in the templates directory. The tag-elements in tags.xml use the same format as described above. The tags have their own default language to prevent that the same tag has different translations in a result of the /Templates operation. This default language is specified in the defaultLang-attribute of the root of tags.xml. Just as with the titles in a template, a translation for the default language must be specified for all tags.

The tag-elements in the templates are now empty but they have an id-attribute instead. These refer to the id-attributes of the tags in tags.xml.

I've added an XML Schema for the tags.xml file and adapted the XML Schema for the templates.

basharmsen commented 3 years ago

This XSLT-stylesheet can be useful when converting templates: ConvertTemplate.zip