fix: Panic on long numerical file names
Closes: #258 [lexical_sort](https://github.com/Aloso/lexical-sort) is currently unmaintained. The author recommends switching to the `icu` crate which is maintained by the Unicode Consortium.
This commit is contained in:
parent
5ec14f86b3
commit
783256fe8b
6 changed files with 622 additions and 28 deletions
|
|
@ -1,9 +1,13 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use i18n_embed::{
|
||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
||||
DefaultLocalizer, LanguageLoader, Localizer,
|
||||
};
|
||||
use icu::collator::{Collator, CollatorOptions, Numeric};
|
||||
use icu_provider::DataLocale;
|
||||
use once_cell::sync::Lazy;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
|
|
@ -21,6 +25,20 @@ pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
|
|||
loader
|
||||
});
|
||||
|
||||
pub static LANGUAGE_SORTER: Lazy<Collator> = Lazy::new(|| {
|
||||
let mut options = CollatorOptions::new();
|
||||
options.numeric = Some(Numeric::On);
|
||||
let collator = {
|
||||
let current = LANGUAGE_LOADER.current_language().to_string();
|
||||
|
||||
let locale = DataLocale::from_str(¤t).unwrap();
|
||||
let collator = Collator::try_new(&locale, options).unwrap();
|
||||
collator
|
||||
};
|
||||
|
||||
collator
|
||||
});
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fl {
|
||||
($message_id:literal) => {{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue