Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://github.com/crate-ci/typos
# install: cargo install typos-cli
# run: typos

# Ignore the contents of localization files (but check their names)
[type.po]
extend-glob = ["*.po"]
check-file = false

[type.ftl]
extend-glob = ["*.ftl"]
check-file = false
24 changes: 12 additions & 12 deletions i18n-build/src/gettext_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@
let xtr_command_name = "xtr";
let mut xtr = Command::new(xtr_command_name);

match &gettext_config.copyright_holder {

Check warning on line 99 in i18n-build/src/gettext_impl/mod.rs

View workflow job for this annotation

GitHub Actions / Clippy

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> i18n-build/src/gettext_impl/mod.rs:99:9 | 99 | / match &gettext_config.copyright_holder { 100 | | Some(copyright_holder) => { 101 | | xtr.args(["--copyright-holder", copyright_holder.as_str()]); ... | 104 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` on by default help: try | 99 ~ if let Some(copyright_holder) = &gettext_config.copyright_holder { 100 + xtr.args(["--copyright-holder", copyright_holder.as_str()]); 101 + } |
Some(copyright_holder) => {
xtr.args(["--copyright-holder", copyright_holder.as_str()]);
}
None => {}
}

match &gettext_config.msgid_bugs_address {

Check warning on line 106 in i18n-build/src/gettext_impl/mod.rs

View workflow job for this annotation

GitHub Actions / Clippy

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> i18n-build/src/gettext_impl/mod.rs:106:9 | 106 | / match &gettext_config.msgid_bugs_address { 107 | | Some(msgid_bugs_address) => { 108 | | xtr.args(["--msgid-bugs-address", msgid_bugs_address.as_str()]); ... | 111 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match help: try | 106 ~ if let Some(msgid_bugs_address) = &gettext_config.msgid_bugs_address { 107 + xtr.args(["--msgid-bugs-address", msgid_bugs_address.as_str()]); 108 + } |
Some(msgid_bugs_address) => {
xtr.args(["--msgid-bugs-address", msgid_bugs_address.as_str()]);
}
Expand Down Expand Up @@ -154,7 +154,7 @@
.with_extension("pot")
}

/// Run the gettext utils `msgcat` command to concatinate pot files
/// Run the gettext utils `msgcat` command to concatenate pot files
/// into a single pot file.
pub fn run_msgcat<P: AsRef<Path>, I: IntoIterator<Item = P>>(
input_pot_paths: I,
Expand All @@ -174,7 +174,7 @@
}

info!(
"Concatinating pot files {0:?} with `msgcat` into \"{1}\"",
"Concatenating pot files {0:?} with `msgcat` into \"{1}\"",
input_pot_paths_strings,
output_pot_path.as_ref().to_string_lossy()
);
Expand Down Expand Up @@ -456,32 +456,32 @@
}

// figure out where there are any subcrates which need their output
// pot files concatinated with this crate's pot file
let mut concatinate_crates = vec![];
// pot files concatenated with this crate's pot file
let mut concatenate_crates = vec![];
for subcrate in &subcrates {
run(subcrate)?;
if subcrate.collated_subcrate() {
concatinate_crates.push(subcrate);
concatenate_crates.push(subcrate);
}
}

// Perform the concatination (if there are any required)
if !concatinate_crates.is_empty() {
// Perform the concatenation (if there are any required)
if !concatenate_crates.is_empty() {
assert!(crt.gettext_config_or_err()?.collate_extracted_subcrates);
concatinate_crates.insert(0, crt);
concatenate_crates.insert(0, crt);

let concatinate_crate_paths: Vec<PathBuf> = concatinate_crates
let concatenate_crate_paths: Vec<PathBuf> = concatenate_crates
.iter()
.map(|concat_crt: &&Crate| crate_module_pot_file_path(concat_crt, &pot_dir))
.collect();

let output_pot_path = crate_module_pot_file_path(crt, &pot_dir);
run_msgcat(concatinate_crate_paths, output_pot_path)?;
run_msgcat(concatenate_crate_paths, output_pot_path)?;

// remove this crate from the list because we don't want to delete it's pot file
concatinate_crates.remove(0);
concatenate_crates.remove(0);

for subcrate in concatinate_crates {
for subcrate in concatenate_crates {
let subcrate_output_pot_path = crate_module_pot_file_path(subcrate, &pot_dir);
util::remove_file_or_error(subcrate_output_pot_path)?;
}
Expand Down
4 changes: 2 additions & 2 deletions i18n-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This library contains the configuration stucts (along with their
//! This library contains the configuration structs (along with their
//! parsing functions) for the
//! [cargo-i18n](https://crates.io/crates/cargo_i18n) tool/system.

Expand Down Expand Up @@ -86,7 +86,7 @@
pub i18n_config: Option<I18nConfig>,
}

impl<'a> Crate<'a> {

Check warning on line 89 in i18n-config/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

warning: elided lifetime has a name --> i18n-config/src/lib.rs:155:58 | 89 | impl<'a> Crate<'a> { | -- lifetime `'a` declared here ... 155 | pub fn active_config(&'a self) -> Result<Option<(&'a Crate, &'a I18nConfig)>, I18nConfigError> { | ^^^^^ this elided lifetime gets resolved as `'a`

Check warning on line 89 in i18n-config/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

warning: elided lifetime has a name --> i18n-config/src/lib.rs:155:58 | 89 | impl<'a> Crate<'a> { | -- lifetime `'a` declared here ... 155 | pub fn active_config(&'a self) -> Result<Option<(&'a Crate, &'a I18nConfig)>, I18nConfigError> { | ^^^^^ this elided lifetime gets resolved as `'a`

Check warning on line 89 in i18n-config/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

warning: elided lifetime has a name --> i18n-config/src/lib.rs:145:29 | 89 | impl<'a> Crate<'a> { | -- lifetime `'a` declared here ... 145 | ) -> Result<Option<(&'a Crate, &'a I18nConfig)>, I18nConfigError> { | ^^^^^ this elided lifetime gets resolved as `'a` | = note: `#[warn(elided_named_lifetimes)]` on by default
/// Read crate from `Cargo.toml` i18n config using the
/// `config_file_path` (if there is one).
pub fn from<P1: Into<PathBuf>, P2: Into<PathBuf>>(
Expand Down Expand Up @@ -142,7 +142,7 @@
/// otherwise return None.
pub fn parent_active_config(
&'a self,
) -> Result<Option<(&'a Crate, &'a I18nConfig)>, I18nConfigError> {

Check warning on line 145 in i18n-config/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

elided lifetime has a name
match self.parent {
Some(parent) => parent.active_config(),
None => Ok(None),
Expand All @@ -152,7 +152,7 @@
/// Identify the config which should be used for this crate, and
/// the crate (either this crate or one of it's parents)
/// associated with that config.
pub fn active_config(&'a self) -> Result<Option<(&'a Crate, &'a I18nConfig)>, I18nConfigError> {

Check warning on line 155 in i18n-config/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

elided lifetime has a name
debug!("Resolving active config for {0}", self);
match &self.i18n_config {
Some(config) => {
Expand Down Expand Up @@ -301,7 +301,7 @@
if this_is_subcrate {
Some(crt)
} else {
debug!("Parent {0} does not have {1} correctly listed as one of its subcrates (curently: {2:?}) in its i18n config.", crt, self, config.subcrates);
debug!("Parent {0} does not have {1} correctly listed as one of its subcrates (currently: {2:?}) in its i18n config.", crt, self, config.subcrates);
None
}
}
Expand Down
12 changes: 6 additions & 6 deletions i18n-embed-fl/examples/web-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ fn main() {

println!(
"requested [en-US], response: {}",
hande_request(&loader, &[&"en-US".parse().unwrap()])
handle_request(&loader, &[&"en-US".parse().unwrap()])
);
println!(
"requested [ka-GE], response: {}",
hande_request(&loader, &[&"ka-GE".parse().unwrap()])
handle_request(&loader, &[&"ka-GE".parse().unwrap()])
);
println!(
"requested [en-UK], response: {}",
hande_request(&loader, &[&"en-UK".parse().unwrap()])
handle_request(&loader, &[&"en-UK".parse().unwrap()])
);
println!(
"requested [de-AT], response: {}",
hande_request(&loader, &[&"de-AT".parse().unwrap()])
handle_request(&loader, &[&"de-AT".parse().unwrap()])
);
println!(
"requested [ru-RU], response: {}",
hande_request(
handle_request(
&loader,
&[&"ru-RU".parse().unwrap(), &"de-DE".parse().unwrap()]
)
);
}

fn hande_request(
fn handle_request(
loader: &FluentLanguageLoader,
requested_languages: &[&unic_langid::LanguageIdentifier],
) -> String {
Expand Down
2 changes: 1 addition & 1 deletion i18n-embed-fl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn domains() -> &'static dashmap::DashMap<String, DomainSpecificData> {
/// runtime using a [HashMap](std::collections::HashMap), using the
/// same signature as in
/// [FluentLanguageLoader::get_args()](i18n_embed::fluent::FluentLanguageLoader::get_args()).
/// When using this method of specifying argments, they are not
/// When using this method of specifying arguments, they are not
/// checked at compile time.
///
/// ### Example
Expand Down
16 changes: 8 additions & 8 deletions i18n-embed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
+ New `autoreload` crate feature.
+ `RustEmbedNotifyAssets` - A wrapper for `rust_embed::RustEmbed` that supports notifications when files have changed on the file system.
+ `FileSystemAssets::notify_changes_enabled()` - A new method to enable watching for changes.
+ `AssetsMultiplexor` - A way to multiplex implmentations of [`I18nAssets`] where assets are multiplexed by a priority.
+ `AssetsMultiplexor` - A way to multiplex implementations of [`I18nAssets`] where assets are multiplexed by a priority.

### Breaking

+ Modified `I18nAssets` trait.
+ Support multiple files referencing the same asset (to allow a heirachy of overrides).
+ Support multiple files referencing the same asset (to allow a hierarchy of overrides).
+ Support for subscribing to updates to assets.
+ Remove deprecated methods for `LanguageConfig`, Please use `lang(...).get_attr_args(...)` etc instead.
+ `LanguageConfig::get_lang()`
Expand Down Expand Up @@ -82,7 +82,7 @@

- A new `LanguageLoader::load_available_languages()` method to load all available languages.
- A new `FluentLanguageLoader::select_languages()` method (renamed `FluentLanguageLoader::lang()`).
- A new `FluentLanguageLoader::select_languages_negotiate()` method to select languages based on a negotiation strategy using the available languges.
- A new `FluentLanguageLoader::select_languages_negotiate()` method to select languages based on a negotiation strategy using the available languages.

### Deprecated

Expand Down Expand Up @@ -179,7 +179,7 @@ done in #84.

### Internal Changes

- Updated `FluentLanguageLoader` to use a thread safe [IntlLangMemoizer](https://docs.rs/intl-memoizer/0.5.1/intl_memoizer/concurrent/struct.IntlLangMemoizer.html) as per the notes on [FluentBundle's concurrency](https://docs.rs/fluent-bundle/0.15.0/fluent_bundle/bundle/struct.FluentBundle.html#concurrency). This was required to solve a compilation error in `i18n-embed-fl` and may also fix problems for other downstream users who were expecting `FluentLangaugeLoader` to be `Send + Sync`. It might impact performance for those who are not using this in multi-threaded context, please report this, and in which case support for switching the `IntlLangMemoizer` added.
- Updated `FluentLanguageLoader` to use a thread safe [IntlLangMemoizer](https://docs.rs/intl-memoizer/0.5.1/intl_memoizer/concurrent/struct.IntlLangMemoizer.html) as per the notes on [FluentBundle's concurrency](https://docs.rs/fluent-bundle/0.15.0/fluent_bundle/bundle/struct.FluentBundle.html#concurrency). This was required to solve a compilation error in `i18n-embed-fl` and may also fix problems for other downstream users who were expecting `FluentLanguageLoader` to be `Send + Sync`. It might impact performance for those who are not using this in multi-threaded context, please report this, and in which case support for switching the `IntlLangMemoizer` added.

## v0.11.0

Expand All @@ -195,7 +195,7 @@ done in #84.

### New Features

- New `LanguageRequester::add_listener_ref()` method to add permenant listeners of type `&dyn Localizer`. This also affects `DesktopLanguageRequester` and `WebLanguageRequester`.
- New `LanguageRequester::add_listener_ref()` method to add permanent listeners of type `&dyn Localizer`. This also affects `DesktopLanguageRequester` and `WebLanguageRequester`.

### Internal Changes

Expand Down Expand Up @@ -255,7 +255,7 @@ done in #84.

## v0.8.6

- Update documentation and example to more accurately reflect the current state of `LangaugeRequester::poll()` on various systems.
- Update documentation and example to more accurately reflect the current state of `LanguageRequester::poll()` on various systems.

## v0.8.5

Expand All @@ -278,7 +278,7 @@ done in #84.

### New Features

- Added a new `with_mesage_iter()` method to `FluentLanguageLoader`, to allow iterating over the messages available for a particular language.
- Added a new `with_message_iter()` method to `FluentLanguageLoader`, to allow iterating over the messages available for a particular language.
- Added `Default` implementation for `WebLanguageRequester`.

## v0.8.2
Expand Down Expand Up @@ -306,7 +306,7 @@ Changes to support the new `i18n-embed-fl` crate's `fl!()` macro, and some major

- Removed `I18nEmbed` trait, and derive macro, it was replaced with the new `I18nAssets` trait.
- Clarified the `domain` and `module` arguments/variable inputs to `FluentLanguageLoader` and `GettextLanguageLoader`, and in the `LanguageLoader` trait with some renaming.
- Removed a bunch of unecessary lifetimes, and `'static` bounds on types, methods and arguments.
- Removed a bunch of unnecessary lifetimes, and `'static` bounds on types, methods and arguments.
- `LanguageRequester::current_languages()`'s return type now uses `String` as the `HashMap` key instead of `&'static str`.
- `available_languages()` implementation moved from `I18nEmbed` to `LanguageLoader`.

Expand Down
2 changes: 1 addition & 1 deletion i18n-embed/examples/library-fluent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub static LOCALIZATIONS: Lazy<RustEmbedNotifyAssets<LocalizationsEmbed>> = Lazy
static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
let loader: FluentLanguageLoader = fluent_language_loader!();

// Load the fallback langauge by default so that users of the
// Load the fallback language by default so that users of the
// library don't need to if they don't care about localization.
loader
.load_fallback_language(&*LOCALIZATIONS)
Expand Down
4 changes: 2 additions & 2 deletions i18n-embed/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn notify_watcher(
/// An entity that watches for changes to localization resources.
///
/// NOTE: Currently we rely in the implicit [`Drop`] implementation to remove file system watches,
/// in the future ther may be new methods added to this trait.
/// in the future there may be new methods added to this trait.
pub trait Watcher {}

#[cfg(feature = "autoreload")]
Expand Down Expand Up @@ -283,7 +283,7 @@ impl I18nAssets for FileSystemAssets {
}
}

/// A way to multiplex implmentations of [`I18nAssets`].
/// A way to multiplex implementations of [`I18nAssets`].
pub struct AssetsMultiplexor {
/// Assets that are multiplexed, ordered from most to least priority.
assets: Vec<Box<dyn I18nAssets + Send + Sync + 'static>>,
Expand Down
2 changes: 1 addition & 1 deletion i18n-embed/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct FluentLanguageLoaderInner {
current_languages: CurrentLanguages,
}

/// [LanguageLoader] implemenation for the `fluent` localization
/// [LanguageLoader] implementation for the `fluent` localization
/// system. Also provides methods to access localizations which have
/// been loaded.
///
Expand Down
4 changes: 2 additions & 2 deletions i18n-embed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
//! LANGUAGE_LOADER.get_or_init(|| {
//! let loader = fluent_language_loader!();
//!
//! // Load the fallback langauge by default so that users of the
//! // Load the fallback language by default so that users of the
//! // library don't need to if they don't care about localization.
//! // This isn't required for the `gettext` localization system.
//! loader.load_fallback_language(&Localizations)
Expand Down Expand Up @@ -526,7 +526,7 @@ pub trait Localizer {
}
}

/// A simple default implemenation of the [Localizer](Localizer) trait.
/// A simple default implementation of the [Localizer](Localizer) trait.
pub struct DefaultLocalizer<'a> {
/// The source of assets used by this localizer.
pub i18n_assets: &'a (dyn I18nAssets + Send + Sync + 'static),
Expand Down
Loading