Implement `Localize` for `std::path` and `camino`
Dependencies
- [2]
RUCC2HKZRename from `fluent_embed` to `l10n_embed` - [3]
USKESL6XAdd examples for using common types in `l10n_embed` - [*]
HHJDRLLNCreate `fluent_embed_runtime` crate - [*]
C6W7N6N5Implement `Localize` for `FixedDecimal` and primitive number types - [*]
WWDZWJTRImplement `Localize` for string types - [*]
AE3AZFVKAdd `Styled<L: Localize>` struct to support localizing colors - [*]
7M4UI3TWUpdate dependencies to latest versions - [*]
UKFEFT6LCreate basic `Output` proc-macro
Change contents
- file addition: path.rs[5.49]
use std::path::{Path, PathBuf};use crate::Localize;use camino::{Utf8Path, Utf8PathBuf};use icu_locale::Locale;macro_rules! impl_std_path {($path_type:ty) => {impl Localize for $path_type {fn localize_for(&self, _locale: &Locale) -> String {self.to_string_lossy().to_string()}}};}macro_rules! impl_camino_path {($path_type:ty) => {impl Localize for $path_type {fn localize_for(&self, _locale: &Locale) -> String {self.to_string()}}};}impl_std_path!(PathBuf);impl_std_path!(Path);impl_camino_path!(Utf8PathBuf);impl_camino_path!(Utf8Path); - edit in l10n_embed/src/lib.rs at line 2
pub mod path; - file addition: path.rs[3.20]
//! Example showing how to localize pathsuse camino::Utf8PathBuf;use icu_locale::{Locale, locale};use l10n_embed::Localize;const DEFAULT_LOCALE: Locale = locale!("en-US");fn main() -> Result<(), std::io::Error> {// Create some pathslet current_directory = std::env::current_dir()?;let current_directory_utf8 = Utf8PathBuf::from_path_buf(current_directory.clone()).unwrap();// Localize these paths, which just prints the path as a string (lossily if using std::path)println!("Current directory: {}",current_directory.localize_for(&DEFAULT_LOCALE));println!("Current directory (UTF-8): {}",current_directory_utf8.localize_for(&DEFAULT_LOCALE));Ok(())} - edit in l10n_embed/Cargo.toml at line 19
camino.workspace = true - edit in Cargo.lock at line 736
"camino",