From 827ea8941f71527ad71b4df39ec30f90d5dff2b6 Mon Sep 17 00:00:00 2001 From: Matthew Foster Date: Thu, 24 Aug 2023 14:53:44 -0700 Subject: [PATCH 1/3] add indication of language used in the resource. this is a mandatory field in our schema which we currently do not populate in the xml --- metadata_xml/iso19115-cioos-template/main.j2 | 58 ++++++++++++++++++++ sample_records/record.yml | 4 ++ 2 files changed, 62 insertions(+) diff --git a/metadata_xml/iso19115-cioos-template/main.j2 b/metadata_xml/iso19115-cioos-template/main.j2 index 3b3d1d1..2d76f58 100644 --- a/metadata_xml/iso19115-cioos-template/main.j2 +++ b/metadata_xml/iso19115-cioos-template/main.j2 @@ -11,6 +11,11 @@ {% set lang_alt_code = language_codes[lang_alt] %} {% set languages_used = list_all_languages_in_record(record) %} +{% set resource_lang = record['identification']['language'] %} +{% set resource_lang_alt = record['identification']['language_alternate'] %} +{% set resource_lang_code = language_codes[resource_lang] %} +{% set resource_lang_alt_code = language_codes[resource_lang_alt] %} + {% import 'bilingual.j2' as bl with context %} {% import 'contact.j2' as contact with context %} {% import 'charstring.j2' as cs %} @@ -621,6 +626,59 @@ {% endfor %} + {% if record['identification']['language'] %} + {# defaultLocale: mandatory #} + + + {# language: mandatory #} + + + {# CIOOS core mandatory element #} + {# MI_Metadata/defaultLocale/PT_Locale/language/LanguageCode (ISO639-2) #} + + + {# country: mandatory #} + + + {# CIOOS core mandatory element #} + {# MI_Metadata/defaultLocale/PT_Locale/country/CountryCode (ISO3166-1) #} + + + {# characterEncoding: mandatory #} + + + {# CIOOS core mandatory element #} + {# MI_Metadata/defaultLocale/PT_Locale/characterEncoding/MD_CharacterSetCode (UTF-8) #} + + + + {% endif %} + {% if record['identification']['language_alternate']%} + + + {# language: mandatory #} + + + {# CIOOS core mandatory element #} + {# MI_Metadata/otherLocale/PT_Locale/language/LanguageCode (ISO639-2) #} + + + {# country: mandatory #} + + + {# CIOOS core mandatory element #} + {# MI_Metadata/otherLocale/PT_Locale/country/CountryCode (ISO3166-1) #} + + + + + {# CIOOS core mandatory element #} + {# MI_Metadata/otherLocale/PT_Locale/characterEncoding/MD_CharacterSetCode (UTF-8) #} + + + + {% endif %} + {{- bl.bilingual('mri:supplementalInformation', 'comment', record['metadata']) -}} diff --git a/sample_records/record.yml b/sample_records/record.yml index 13fcd98..0c12dda 100644 --- a/sample_records/record.yml +++ b/sample_records/record.yml @@ -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 @@ -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 From 989bb697bf46930c2c701058ea90359aa936d716 Mon Sep 17 00:00:00 2001 From: Matthew Foster Date: Tue, 21 Nov 2023 16:13:10 -0800 Subject: [PATCH 2/3] remove unused variables --- metadata_xml/iso19115-cioos-template/main.j2 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/metadata_xml/iso19115-cioos-template/main.j2 b/metadata_xml/iso19115-cioos-template/main.j2 index 2d76f58..2c0a2c0 100644 --- a/metadata_xml/iso19115-cioos-template/main.j2 +++ b/metadata_xml/iso19115-cioos-template/main.j2 @@ -1,20 +1,14 @@ {% 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 = record['identification']['language'] %} -{% set resource_lang_alt = record['identification']['language_alternate'] %} -{% set resource_lang_code = language_codes[resource_lang] %} -{% set resource_lang_alt_code = language_codes[resource_lang_alt] %} +{% 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 %} From 4cec7d47095d9f540b7a3b0ab2a88ca79d4f62bb Mon Sep 17 00:00:00 2001 From: Matthew Foster Date: Tue, 21 Nov 2023 16:16:32 -0800 Subject: [PATCH 3/3] check resource language is set when generating xml --- metadata_xml/iso19115-cioos-template/main.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata_xml/iso19115-cioos-template/main.j2 b/metadata_xml/iso19115-cioos-template/main.j2 index 2c0a2c0..0a16983 100644 --- a/metadata_xml/iso19115-cioos-template/main.j2 +++ b/metadata_xml/iso19115-cioos-template/main.j2 @@ -620,7 +620,7 @@ {% endfor %} - {% if record['identification']['language'] %} + {% if record['identification']['language'] and resource_lang_code %} {# defaultLocale: mandatory #} @@ -647,7 +647,7 @@ {% endif %} - {% if record['identification']['language_alternate']%} + {% if record['identification']['language_alternate'] and resource_lang_alt_code %} {# language: mandatory #}