[gnome-desktop/issue-202: 2/4] Refactor gnome-gettext-portable.h
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop/issue-202: 2/4] Refactor gnome-gettext-portable.h
- Date: Sat, 27 Nov 2021 18:37:55 +0000 (UTC)
commit 8e0f783711dd0271d46e4dbe8c70460cb0175bf2
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat Nov 27 17:38:20 2021 +0000
Refactor gnome-gettext-portable.h
- Do not include "config.h"
- Leave conditionally including xlocale.h to source files
- Add an error for missing GETTEXT_PACKAGE
- Rename non-idiomatic `_l` macro to `L_`
libgnome-desktop/gnome-gettext-portable.h | 26 +++++++++++++++-----------
libgnome-desktop/gnome-languages.c | 18 +++++++++++-------
2 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/libgnome-desktop/gnome-gettext-portable.h b/libgnome-desktop/gnome-gettext-portable.h
index 9dd65712..69098885 100644
--- a/libgnome-desktop/gnome-gettext-portable.h
+++ b/libgnome-desktop/gnome-gettext-portable.h
@@ -18,29 +18,33 @@
*
*/
-#include "config.h"
+#include <glib.h>
#include <locale.h>
#include <string.h>
-#ifdef HAVE_XLOCALE
-#include <xlocale.h>
+#ifndef GETTEXT_PACKAGE
+#error "You must define GETTEXT_PACKAGE before including gnome-gettext-portable.h; did you forget to include
config.h?"
#endif
+G_BEGIN_DECLS
+
const char *
dgettext_l (locale_t locale,
const char *domain,
const char *msgid);
const gchar *
-g_dgettext_l (locale_t locale,
- const gchar *domain,
- const gchar *msgid);
+g_dgettext_l (locale_t locale,
+ const char *domain,
+ const char *msgid);
const gchar *
-g_dpgettext_l (locale_t locale,
- const gchar *domain,
- const gchar *msgctxtid,
- gsize msgidoffset);
+g_dpgettext_l (locale_t locale,
+ const char *domain,
+ const char *msgctxtid,
+ gsize msgidoffset);
+
+#define L_(Locale,String) ((char *) g_dgettext_l (Locale, GETTEXT_PACKAGE, String))
-#define _l(locale_t,String) ((char *) g_dgettext_l (locale_t, GETTEXT_PACKAGE, String))
+G_END_DECLS
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
index c4de0e62..7a0ef6ba 100644
--- a/libgnome-desktop/gnome-languages.c
+++ b/libgnome-desktop/gnome-languages.c
@@ -35,6 +35,10 @@
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
+#ifdef HAVE_XLOCALE
+#include <xlocale.h>
+#endif
+
#include "gnome-gettext-portable.h"
#define GNOME_DESKTOP_USE_UNSTABLE_API
@@ -1378,26 +1382,26 @@ gnome_get_translated_modifier (const char *modifier,
/* TRANSLATORS: Used to distinguish the labels representing the gez_ER
and gez_ET locales from gez_ER@abegede respective gez_ET@abegede. The
difference is related to collation. */
- g_hash_table_insert (modifiers_map, "abegede", _l(loc, "Abegede"));
+ g_hash_table_insert (modifiers_map, "abegede", L_(loc, "Abegede"));
/* TRANSLATORS: Used to distinguish Cyrillic from Latin written language variants. */
- g_hash_table_insert (modifiers_map, "cyrillic", _l(loc, "Cyrillic"));
+ g_hash_table_insert (modifiers_map, "cyrillic", L_(loc, "Cyrillic"));
/* TRANSLATORS: Also known as "Nagari", a written variant for many languages
of the Indian subcontinent. See:
https://en.wikipedia.org/wiki/Devanagari */
- g_hash_table_insert (modifiers_map, "devanagari", _l(loc, "Devanagari"));
+ g_hash_table_insert (modifiers_map, "devanagari", L_(loc, "Devanagari"));
/* TRANSLATORS: Used to distinguish the label representing the tt_RU
locale from tt_RU@iqtelif. It's a special alphabet for Tatar. */
- g_hash_table_insert (modifiers_map, "iqtelif", _l(loc, "IQTElif"));
+ g_hash_table_insert (modifiers_map, "iqtelif", L_(loc, "IQTElif"));
/* TRANSLATORS: The alphabet/script, not the language. Used to distinguish
Latin from Cyrillic written language variants. */
- g_hash_table_insert (modifiers_map, "latin", _l(loc, "Latin"));
+ g_hash_table_insert (modifiers_map, "latin", L_(loc, "Latin"));
/* TRANSLATORS: "Saho" is a variant of the Afar language. Used to
distinguish the label representing the aa_ER locale from aa_ER@saaho. */
- g_hash_table_insert (modifiers_map, "saaho", _l(loc, "Saho"));
+ g_hash_table_insert (modifiers_map, "saaho", L_(loc, "Saho"));
/* TRANSLATORS: "Valencia" is a dialect of the Catalan language spoken
in Valencia. Used to distinguish the label representing the ca_ES
locale from ca_ES@valencia. */
- g_hash_table_insert (modifiers_map, "valencia", _l(loc, "Valencia"));
+ g_hash_table_insert (modifiers_map, "valencia", L_(loc, "Valencia"));
if (g_hash_table_contains (modifiers_map, modifier))
retval = g_strdup (g_hash_table_lookup (modifiers_map, modifier));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]