Skip to content

Commit

Permalink
update bilingual template to handle translation key
Browse files Browse the repository at this point in the history
  • Loading branch information
fostermh committed Feb 15, 2024
1 parent 9b96ccc commit c2bd604
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
10 changes: 6 additions & 4 deletions metadata_xml/iso19115-cioos-template/bilingual.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro bilingual(element,key,record_section, translationKey) -%}
{% macro bilingual(element,key,record_section) -%}
{% set value = record_section[key] %}

{% if (value is not mapping) or (value.items()|length==1 and lang in value) %}
Expand All @@ -17,10 +17,12 @@
<gco:CharacterString>{{- value[lang]|e -}}</gco:CharacterString>
{% endif %}
<lan:PT_FreeText>
{% set translations = value.get("translations", {})%}
{% for secondary_lang,val in value.items() %}
{% if secondary_lang != lang %}
{% if translationKey %}
<lan:textGroup xlink:href="https://cioos.ca/translation_method" xlink:role="translation" xlink:title="{{record_section[translationKey]}}">
{% if secondary_lang != lang and secondary_lang != 'translations'%}
{% set translationMessage = translations.get(secondary_lang,{}).get("message")%}
{% if translationMessage %}
<lan:textGroup xlink:href="https://cioos.ca/translation_method" xlink:role="translation" xlink:title="{{translationMessage}}">
{% else %}
<lan:textGroup>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions metadata_xml/iso19115-cioos-template/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
<mri:citation>
<cit:CI_Citation>
{# title: mandatory #}
{{- bl.bilingual('cit:title','title', record['identification'], 'titleTranslationMethod') -}}
{{- bl.bilingual('cit:title','title', record['identification']) -}}

{# date pubished/revised isnt required #}
{% if 'dates' in record['identification'] %}
Expand Down Expand Up @@ -283,7 +283,7 @@
{# abstract: mandatory #}
{# CIOOS core mandatory element #}
{# MI_Metadata/identificationInfo/MD_DataIdentification/abstract/CharacterString #}
{{- bl.bilingual('mri:abstract', 'abstract', record['identification'], 'abstractTranslationMethod') -}}
{{- bl.bilingual('mri:abstract', 'abstract', record['identification']) -}}
{{- bl.bilingual('mri:credit', 'acknowledgement', record['identification']) -}}
<mri:status>
<mcc:MD_ProgressCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_ProgressCode" codeListValue="{{- record['identification']['progress_code'] or 'onGoing' -}}">
Expand Down Expand Up @@ -586,7 +586,7 @@
{# MD_Constraints: CIOOS core mandatory #}
<mco:MD_Constraints>
{# useLimitation: CIOOS core mandatory #}
{{- bl.bilingual('mco:useLimitation', 'limitations', record['metadata']['use_constraints'], 'limitationsTranslationMethod') -}}
{{- bl.bilingual('mco:useLimitation', 'limitations', record['metadata']['use_constraints']) -}}
</mco:MD_Constraints>
</mri:resourceConstraints>
{% endif %}
Expand Down Expand Up @@ -757,7 +757,7 @@
{# description: mandatory #}
{# CIOOS core mandatory element #}
{# MI_Metadata/acquisitionInformation/MI_AcquisitionInformation/platform/MI_Platform/description/CharacterString #}
{{- bl.bilingual('mac:description', 'description', record['platform'], 'platformDescriptionTranslationMethod') -}}
{{- bl.bilingual('mac:description', 'description', record['platform']) -}}

{% for instrument in record['platform']['instruments'] %}
{# instrument: Recommended, if platform not used then this should be under mac:MI_AcquisitionInformation #}
Expand Down
20 changes: 16 additions & 4 deletions sample_records/record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ metadata:
limitations:
en: limitations in english
fr: limitations in french
limitationsTranslationMethod: Auto-translated using AWS
translations:
fr:
validated: false
message: Auto-translated using AWS
licence:
title: Creative Commons Attribution 4.0
code: CC-BY-4.0
Expand All @@ -41,13 +44,19 @@ identification:
title:
en: title in english
fr: title in french
titleTranslationMethod: Auto-translated using AWS
translations:
fr:
validated: false
message: Auto-translated using AWS
identifier: http://dx.doi.org/10.1093/ajae/aaq063

abstract:
en: abstract in english
fr: abstract in french
abstractTranslationMethod: Auto-translated using AWS
translations:
fr:
validated: false
message: Auto-translated using AWS
associated_resources:
- title:
en: associated resource title in english
Expand Down Expand Up @@ -131,7 +140,10 @@ platform:
description:
en: platformDescription in English
fr: platformDescription in French
platformDescriptionTranslationMethod: Auto-translated using AWS
translations:
fr:
validated: true
message: Auto-translated using AWS
instruments:
- id: 123
manufacturer: manufacturer en 1
Expand Down

0 comments on commit c2bd604

Please sign in to comment.