#locale #posix #localization #country-code

locale-codes

locale-related codes/identifiers and any standards-based information concerning them

2 unstable releases

0.3.0 Aug 26, 2019
0.2.0 Aug 26, 2019

#341 in Internationalization (i18n)

Download history 29/week @ 2024-03-11 31/week @ 2024-03-18 33/week @ 2024-03-25 74/week @ 2024-04-01 19/week @ 2024-04-08 42/week @ 2024-04-15 35/week @ 2024-04-22 24/week @ 2024-04-29 53/week @ 2024-05-06 41/week @ 2024-05-13 53/week @ 2024-05-20 23/week @ 2024-05-27 21/week @ 2024-06-03 19/week @ 2024-06-10 22/week @ 2024-06-17 34/week @ 2024-06-24

97 downloads per month
Used in 5 crates (3 directly)

MIT license

285KB
874 lines

Contains (MSI installer, 96KB) src-data/iso-4217/list_one.xls

Crate locale-codes

travis.ci crates.io docs.rs Minimum Rust Version mit License GitHub stars

This crate provides locale-related codes/identifiers and any standards-based information concerning them. For example, ISO-396 language identifiers, or ISO-3166 country identifiers.

Example

use locale_codes::codes::{country, currency, region};

let mexico = country::lookup_country("MEX").unwrap();
println!("{:?}", mexico);

let mexico_region = country::lookup_region(mexico.country_code).unwrap();
println!("{:?}", mexico_region);

let currencies = currency::currencies_for_country_name(mexico_region.name.as_str());
println!("{:?}", currencies);

Pre-Build Process

The following describe two code generation steps that are executed outside the normal build process as the output is stored in Git and versioned based on external factors.

JSON Data Files

The script create-data-modules on the other hand is used to process files downloaded, or scraped, from standards web sites to create data used by the library. This data is generated as JSON files in the src/codes/data folder and read as a part of the build for codes modules using the Rust include! macro.

Currently data is generated for the following standards:

  • ISO 639 Codes for the representation of names of languages; Parts 1-4, 2-character and 3-character codes supported.
  • ISO 3166 Codes for the representation of names of countries and their subdivisions; Part 1, 2-character codes, only.
  • ISO 4217 Codes for the representation of currencies; alphabetic and numeric codes supported.
  • ISO 15924 Codes for the representation of names of scripts; alphabetic and numeric codes supported.

History

  • 0.3.0 - collapsed module hierarchy.
  • 0.2.0 - extracted from simple-locale.

TODO

  • Determine naming convention between the names in the codes and settings crates.
    • Expect that the names in code modules will be changed to reflect those in the settings.

Dependencies

~2.9–4.5MB
~88K SLoC