Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set language(s) used in the resource #108

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions metadata_xml/iso19115-cioos-template/main.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

{% set lang = record['metadata']['language'] %}
{% set lang_alt = record['metadata']['language_alternate'] %}
{% set language_codes = {"en":"eng",
"fr":"fra",
}
%}
{% set lang_code = language_codes[lang] %}

{% set lang_alt_code = language_codes[lang_alt] %}
{% set languages_used = list_all_languages_in_record(record) %}
{% set resource_lang_code = language_codes[record['identification']['language']] %}
{% set resource_lang_alt_code = language_codes[record['identification']['language_alternate']] %}

{% import 'bilingual.j2' as bl with context %}
{% import 'contact.j2' as contact with context %}
Expand Down Expand Up @@ -621,6 +620,59 @@
</mri:associatedResource>
{% endfor %}

{% if record['identification']['language'] and resource_lang_code %}
{# defaultLocale: mandatory #}
<mri:defaultLocale>
<lan:PT_Locale>
{# language: mandatory #}
<lan:language>
<lan:LanguageCode codeList="http://standards.iso.org/iso/19115/resources/Codelist/lan/LanguageCode.xml" codeListValue="{{- resource_lang_code -}}">
Copy link
Member

@n-a-t-e n-a-t-e Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if resource_lang_code is required, would be good to add to the if statement above. But maybe its not required for validity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, It's a valid iso record without it. The CIOOS standard requires it however. I will include a check and not generate the xml snippet if false

{# CIOOS core mandatory element #}
{# MI_Metadata/defaultLocale/PT_Locale/language/LanguageCode (ISO639-2) #}
</lan:LanguageCode>
</lan:language>
{# country: mandatory #}
<lan:country>
<lan:CountryCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml" codeListValue="CAN">
{# CIOOS core mandatory element #}
{# MI_Metadata/defaultLocale/PT_Locale/country/CountryCode (ISO3166-1) #}
</lan:CountryCode>
</lan:country>
{# characterEncoding: mandatory #}
<lan:characterEncoding>
<lan:MD_CharacterSetCode codeList="http://standards.iso.org/iso/19115/resources/Codelist/lan/CharacterSetCode.xml" codeListValue="utf8" />
{# CIOOS core mandatory element #}
{# MI_Metadata/defaultLocale/PT_Locale/characterEncoding/MD_CharacterSetCode (UTF-8) #}
</lan:characterEncoding>
</lan:PT_Locale>
</mri:defaultLocale>
{% endif %}
{% if record['identification']['language_alternate'] and resource_lang_alt_code %}
<mri:otherLocale>
<lan:PT_Locale>
{# language: mandatory #}
<lan:language>
<lan:LanguageCode codeList="http://standards.iso.org/iso/19115/resources/Codelist/lan/LanguageCode.xml" codeListValue="{{- resource_lang_alt_code -}}">
{# CIOOS core mandatory element #}
{# MI_Metadata/otherLocale/PT_Locale/language/LanguageCode (ISO639-2) #}
</lan:LanguageCode>
</lan:language>
{# country: mandatory #}
<lan:country>
<lan:CountryCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml" codeListValue="CAN">
{# CIOOS core mandatory element #}
{# MI_Metadata/otherLocale/PT_Locale/country/CountryCode (ISO3166-1) #}
</lan:CountryCode>
</lan:country>
<lan:characterEncoding>
<lan:MD_CharacterSetCode codeList="http://standards.iso.org/iso/19115/resources/Codelist/lan/CharacterSetCode.xml" codeListValue="utf8" />
{# CIOOS core mandatory element #}
{# MI_Metadata/otherLocale/PT_Locale/characterEncoding/MD_CharacterSetCode (UTF-8) #}
</lan:characterEncoding>
</lan:PT_Locale>
</mri:otherLocale>
{% endif %}

{{- bl.bilingual('mri:supplementalInformation', 'comment', record['metadata']) -}}
</mri:MD_DataIdentification>
</mdb:identificationInfo>
Expand Down
4 changes: 4 additions & 0 deletions sample_records/record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metadata:
naming_authority: ca.cioos
identifier: 3f342f64-9348-11df-ba6a-0014c2c00eab
language: en
language_alternate: fr
maintenance_note: maintenance_note
use_constraints:
limitations: limitations
Expand All @@ -35,6 +36,9 @@ spatial:
vertical: [0, 10]
vertical_positive: down
identification:
language: en
language_alternate: fr

title:
en: title in english
fr: title in french
Expand Down
Loading