[gnome-tour] Fix missing translatable strings
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tour] Fix missing translatable strings
- Date: Tue, 18 Aug 2020 16:59:49 +0000 (UTC)
commit e4e9163df24e1da976d759fc8dd5ca1bd669d479
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Tue Aug 18 18:59:27 2020 +0200
Fix missing translatable strings
closes #19
data/resources.gresource.xml | 1 -
po/meson.build | 8 +++++++-
src/utils.rs | 2 +-
src/widgets/pages/welcome.rs | 5 +++--
src/widgets/window.rs | 5 +++--
5 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/data/resources.gresource.xml b/data/resources.gresource.xml
index 19c7242..688446a 100644
--- a/data/resources.gresource.xml
+++ b/data/resources.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Tour/">
<file compressed="true" alias="style.css">resources/style.css</file>
- <file alias="welcome.mp4">resources/assets/welcome.mp4</file>
<file compressed="true" alias="activities.svg">resources/assets/activities.svg</file>
<file compressed="true" alias="calendar.svg">resources/assets/calendar.svg</file>
<file compressed="true" alias="search.svg">resources/assets/search.svg</file>
diff --git a/po/meson.build b/po/meson.build
index 57d1266..bfc35fd 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1 +1,7 @@
-i18n.gettext(gettext_package, preset: 'glib')
+i18n.gettext(
+ gettext_package,
+ args: [
+ '--keyword=i18n_f'
+ ],
+ preset: 'glib'
+)
diff --git a/src/utils.rs b/src/utils.rs
index e47f286..c3eb8fe 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -17,7 +17,7 @@ where
pub fn i18n_f(format: &str, args: &[&str]) -> String {
let s = gettext(format);
let mut parts = s.split("{}");
- let mut output = parts.next().unwrap_or("").to_string();
+ let mut output = parts.next().unwrap_or_default().to_string();
for (p, a) in parts.zip(args.iter()) {
output += &(a.to_string() + &p.to_string());
}
diff --git a/src/widgets/pages/welcome.rs b/src/widgets/pages/welcome.rs
index 82f58fe..53b4f4b 100644
--- a/src/widgets/pages/welcome.rs
+++ b/src/widgets/pages/welcome.rs
@@ -1,5 +1,6 @@
#[cfg(feature = "video")]
use crate::config;
+use crate::utils::i18n_f;
use gettextrs::gettext;
#[cfg(feature = "video")]
use gio::FileExt;
@@ -140,8 +141,8 @@ impl WelcomePageWidget {
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let version = glib::get_os_info("VERSION").unwrap_or_else(|| "3.36".into());
-
- let title = gtk::Label::new(Some(&gettext(format!("Welcome to {} {}", name, version))));
+ // Translators: The following string is formated as "Welcome to GNOME 3.36" for example
+ let title = gtk::Label::new(Some(&i18n_f("Welcome to {} {}", &[&name, &version])));
title.set_margin_top(36);
title.get_style_context().add_class("large-title");
title.show();
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index b42d193..91902e3 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -1,4 +1,4 @@
-use crate::utils;
+use crate::utils::i18n_f;
use gettextrs::gettext;
use gtk::prelude::*;
use std::cell::RefCell;
@@ -97,7 +97,8 @@ impl Window {
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let last_page = ImagePageWidget::new(
"/org/gnome/Tour/ready-to-go.svg",
- utils::i18n_f("That's it! We hope that you enjoy {}.", &[&name]),
+ // Translators: The following string is formated as "We hope that you enjoy GNOME"
+ i18n_f("That's it! We hope that you enjoy {}.", &[&name]),
gettext("To get more advice and tips, see the Help app."),
);
last_page.widget.get_style_context().add_class("last-page");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]