Skip to content

Commit

Permalink
233 auto translation flag (#109)
Browse files Browse the repository at this point in the history
* fix sample command

* update sample yml and jinja templates for translation message

* update bilingual template to handle translation key

---------

Co-authored-by: Matthew Foster <[email protected]>
  • Loading branch information
sorochak and fostermh authored Feb 15, 2024
1 parent 2d9e7c6 commit c8f30b2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ __pycache__
*.egg-info

venv/
env/
.vscode
.mypy*
notforrepo
*.xml
cioos-schema
build
build
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To convert a Yaml file to XML, run:

eg:

`python -m metadata_xml -f sample_records/record.yaml`
`python -m metadata_xml -f sample_records/record.yml`

## Importing into other Python projects

Expand Down
8 changes: 7 additions & 1 deletion metadata_xml/iso19115-cioos-template/bilingual.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
<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 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 %}
<lan:LocalisedCharacterString locale="#{{secondary_lang}}">{{- val|e -}}</lan:LocalisedCharacterString>
</lan:textGroup>
{% endif %}
Expand Down
24 changes: 22 additions & 2 deletions sample_records/record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ metadata:
language: en
maintenance_note: maintenance_note
use_constraints:
limitations: limitations
limitations:
en: limitations in english
fr: limitations in french
translations:
fr:
validated: false
message: Auto-translated using AWS
licence:
title: Creative Commons Attribution 4.0
code: CC-BY-4.0
Expand All @@ -40,11 +46,19 @@ identification:
title:
en: title in english
fr: title in french
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
translations:
fr:
validated: false
message: Auto-translated using AWS
associated_resources:
- title:
en: associated resource title in english
Expand Down Expand Up @@ -125,7 +139,13 @@ platform:
name: platform_name
authority: platform_authority
id: platform id
description: platform_description
description:
en: platformDescription in English
fr: platformDescription in French
translations:
fr:
validated: true
message: Auto-translated using AWS
instruments:
- id: 123
manufacturer: manufacturer en 1
Expand Down

0 comments on commit c8f30b2

Please sign in to comment.