Skip to content
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
6 changes: 6 additions & 0 deletions codes-iso-3166/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ fn process_part_2_name_data(
};
row.insert("name".to_string(), name.into());

if record.get(6).map(|lang| lang == "eng").unwrap_or(false) {
if let Some(iso_name) = record.get(7) {
row.insert("iso_name".to_string(), iso_name.to_string().into());
}
}

let name_local_variation = record.get(8).unwrap().to_string();
if !name_local_variation.is_empty() {
row.insert(
Expand Down
8 changes: 8 additions & 0 deletions codes-iso-3166/templates/part_2._rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,12 @@ impl {{ type_name }} {{ "{" }}
_ => None,
{{ "}" }}
{{ "}" }}

/// Returns the name corresponding to the name in iso-codes of this subdivision's name.
pub const fn iso_code_name(&self) -> Option<&'static str> {{ "{" }}
match self {{ "{" }}{% for id in all_ids %}{% if codes[id].iso_name %}
Self::{{ id }} => Some("{{ codes[id].iso_name }}"),{% endif %}{% endfor %}
_ => None,
{{ "}" }}
{{ "}" }}
{{ "}" }}