#japanese #localization #prefecture

jp-prefecture

an utility crate of using Japanese prefectures

9 stable releases (3 major)

3.1.0 Apr 2, 2023
3.0.0 Apr 2, 2023
2.0.0 Mar 29, 2023
1.0.5 Mar 28, 2023
0.1.1 Apr 7, 2022

#60 in Internationalization (i18n)

MIT license

77KB
1.5K SLoC

Crates.io Docs.rs Crates.io Test

jp-prefecture

jp-prefecture is an utility library for handling Japanese prefectures.

Getting Started

Crate has to be added as dependency to Cargo.toml

[dependencies]
jp-prefecture = "3.1.0"

and imported to the scope of a block where it's begin called

use jp_prefecture::prefectures;

Examples

use jp_prefecture::prefectures;

let tokyo = prefectures::find_by_kanji("東京都");
println!("{:?}", tokyo); // => Ok(Prefecture::Tokyo)
println!("{:?}", tokyo.as_ref().unwrap().kanji()); // => "東京都"
println!("{:?}", tokyo.as_ref().unwrap().kanji_short()); // => "東京"
println!("{:?}", tokyo.as_ref().unwrap().english()); // => "Tokyo"

let tokyo = prefectures::find_by_kanji("東京県"); // uhmmmm...
println!("{:?}", tokyo); // => Err(Error::InvalidPrefectureName("東京県"))

Dependencies

~0.4–0.8MB
~19K SLoC