edit: Use filename with (Edited) suffix for "Save As"
This commit is contained in:
parent
e2785d9154
commit
9fbe091f1a
5 changed files with 59 additions and 8 deletions
|
|
@ -15,21 +15,28 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
pub use gettextrs::gettext;
|
||||
|
||||
fn freplace(mut s: String, args: impl IntoIterator<Item = impl AsRef<str>>) -> String {
|
||||
fn freplace(mut s: String, args: impl IntoIterator<Item = impl Display>) -> String {
|
||||
for arg in args {
|
||||
s = s.replacen("{}", arg.as_ref(), 1);
|
||||
s = s.replacen("{}", &arg.to_string(), 1);
|
||||
}
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn gettext_f(format: &str, args: impl IntoIterator<Item = impl AsRef<str>>) -> String {
|
||||
pub fn gettext_f(format: &str, args: impl IntoIterator<Item = impl Display>) -> String {
|
||||
let s = ugettext(format);
|
||||
freplace(s, args)
|
||||
}
|
||||
|
||||
pub fn ngettext(format: &str, format_plural: &str, n: u32) -> String {
|
||||
let s = gettextrs::ngettext(format, format_plural, n);
|
||||
freplace(apply_unicode_escapes(&s).unwrap_or(s), [n])
|
||||
}
|
||||
|
||||
/// Same as `gettext` but evaluates unicode escape sequences
|
||||
pub fn ugettext(msgid: &str) -> String {
|
||||
let msg = gettext(msgid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue