i18n: Use gettext function instead of wrapper
No need to deviate from the default here. Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/170>
This commit is contained in:
parent
695693cf74
commit
f8cc9f5f84
16 changed files with 83 additions and 274 deletions
|
|
@ -2,7 +2,7 @@
|
|||
use super::*;
|
||||
use crate::decoder::tiling::{self, FrameBufferExt};
|
||||
use crate::deps::*;
|
||||
use crate::i18n::*;
|
||||
use crate::util::gettext::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use anyhow::Context;
|
||||
|
|
@ -28,7 +28,7 @@ impl Heif {
|
|||
log::debug!("Loading HEIF");
|
||||
updater.spawn_error_handled(move || {
|
||||
let ctx = HeifContext::read_from_file(&path.display().to_string())
|
||||
.context(i18n("Failed to read image"))?;
|
||||
.context(gettext("Failed to read image"))?;
|
||||
let handle = ctx.primary_image_handle()?;
|
||||
|
||||
tiles.set_original_dimensions((handle.width(), handle.height()));
|
||||
|
|
@ -61,7 +61,7 @@ impl Heif {
|
|||
|
||||
let mut image = LIBHEIF
|
||||
.decode(&handle, ColorSpace::Rgb(rgb_chroma), None)
|
||||
.context(i18n("Failed to decode image"))?;
|
||||
.context(gettext("Failed to decode image"))?;
|
||||
|
||||
let plane = image
|
||||
.planes_mut()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use super::*;
|
||||
use crate::decoder::tiling::{self, FrameBufferExt};
|
||||
use crate::deps::*;
|
||||
use crate::i18n::*;
|
||||
use crate::util::gettext::*;
|
||||
|
||||
use anyhow::Context;
|
||||
use arc_swap::ArcSwap;
|
||||
|
|
@ -35,7 +35,8 @@ impl ImageRsOther {
|
|||
path: &Path,
|
||||
format: image_rs::ImageFormat,
|
||||
) -> anyhow::Result<image_rs::io::Reader<BufReader<File>>> {
|
||||
let mut reader = image_rs::io::Reader::open(path).context(i18n("Failed to open image"))?;
|
||||
let mut reader =
|
||||
image_rs::io::Reader::open(path).context(gettext("Failed to open image"))?;
|
||||
reader.set_format(format);
|
||||
Ok(reader)
|
||||
}
|
||||
|
|
@ -88,7 +89,7 @@ impl ImageRsOther {
|
|||
|
||||
reader.limits(image_rs::io::Limits::no_limits());
|
||||
|
||||
let dynamic_image = reader.decode().context(i18n("Failed to decode image"))?;
|
||||
let dynamic_image = reader.decode().context(gettext("Failed to decode image"))?;
|
||||
|
||||
let decoded_image = Decoded { dynamic_image };
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ pub use image_rs_other::ImageRsOther;
|
|||
pub use svg::{Svg, RSVG_MAX_SIZE};
|
||||
|
||||
use super::{Decoder, DecoderUpdate, UpdateSender};
|
||||
use crate::i18n::*;
|
||||
use crate::util::gettext::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum ImageFormat {
|
||||
|
|
@ -52,9 +52,9 @@ impl std::fmt::Display for ImageFormat {
|
|||
write!(f, "{}", debug)
|
||||
}
|
||||
}
|
||||
Self::AnimatedGif => write!(f, "{}", i18n("Animated GIF")),
|
||||
Self::AnimatedWebP => write!(f, "{}", i18n("Animated WebP")),
|
||||
Self::AnimatedPng => write!(f, "{}", i18n("Animated PNG")),
|
||||
Self::AnimatedGif => write!(f, "{}", gettext("Animated GIF")),
|
||||
Self::AnimatedWebP => write!(f, "{}", gettext("Animated WebP")),
|
||||
Self::AnimatedPng => write!(f, "{}", gettext("Animated PNG")),
|
||||
Self::Heif => write!(f, "HEIF Container"),
|
||||
Self::Svg => write!(f, "SVG"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ pub mod tiling;
|
|||
pub use formats::ImageDimensionDetails;
|
||||
|
||||
use crate::deps::*;
|
||||
use crate::i18n::*;
|
||||
use crate::image_metadata::ImageMetadata;
|
||||
use crate::util::gettext::*;
|
||||
use formats::*;
|
||||
use tiling::FrameBufferExt;
|
||||
|
||||
|
|
@ -116,10 +116,10 @@ impl Decoder {
|
|||
update_sender.send(DecoderUpdate::Metadata(ImageMetadata::load(&path)));
|
||||
|
||||
let mut buf = Vec::new();
|
||||
let file = std::fs::File::open(&path).context(i18n("Could not open image"))?;
|
||||
let file = std::fs::File::open(&path).context(gettext("Could not open image"))?;
|
||||
file.take(64)
|
||||
.read_to_end(&mut buf)
|
||||
.context(i18n("Could not read image"))?;
|
||||
.context(gettext("Could not read image"))?;
|
||||
|
||||
// Try magic bytes first and than file name extension
|
||||
let format =
|
||||
|
|
@ -166,12 +166,15 @@ impl Decoder {
|
|||
update_sender.send(DecoderUpdate::Format(ImageFormat::Heif));
|
||||
return Ok(FormatDecoder::Heif(Heif::new(path, update_sender, tiles)));
|
||||
} else {
|
||||
bail!(i18n_f("Unknown image format: {}", &[content_type.as_str()]));
|
||||
bail!(gettext_f(
|
||||
"Unknown image format: {}",
|
||||
&[content_type.as_str()]
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bail!(i18n("Unknown image format"))
|
||||
bail!(gettext("Unknown image format"))
|
||||
}
|
||||
|
||||
/// Request missing tiles
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue