mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Bug 503071 - Application direction changes to right to left even if theres
2008-05-20 14:31:18 Tim Janik <timj@imendio.com> * reverted recent unapproved changes by Yair Hershkovitz, regarding: Bug 503071 - Application direction changes to right to left even if theres no translation. svn path=/trunk/; revision=6919
This commit is contained in:
parent
7100c410d2
commit
8fb03be5a9
@ -1,3 +1,8 @@
|
|||||||
|
2008-05-20 14:31:18 Tim Janik <timj@imendio.com>
|
||||||
|
|
||||||
|
* reverted recent unapproved changes by Yair Hershkovitz, regarding:
|
||||||
|
Bug 503071 – Application direction changes to right to left even if theres no translation.
|
||||||
|
|
||||||
2008-05-20 Tor Lillqvist <tml@novell.com>
|
2008-05-20 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* configure.in: Don't need memory barriers when using a non-gcc
|
* configure.in: Don't need memory barriers when using a non-gcc
|
||||||
|
@ -164,8 +164,7 @@ libglib_2_0_la_SOURCES = \
|
|||||||
gutils.c \
|
gutils.c \
|
||||||
gdebug.h \
|
gdebug.h \
|
||||||
gprintf.c \
|
gprintf.c \
|
||||||
gprintfint.h \
|
gprintfint.h
|
||||||
gi18n.c
|
|
||||||
|
|
||||||
EXTRA_libglib_2_0_la_SOURCES = \
|
EXTRA_libglib_2_0_la_SOURCES = \
|
||||||
giounix.c \
|
giounix.c \
|
||||||
|
@ -21,13 +21,14 @@
|
|||||||
#define __G_I18N_LIB_H__
|
#define __G_I18N_LIB_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
|
||||||
|
#include <libintl.h>
|
||||||
|
|
||||||
#ifndef GETTEXT_PACKAGE
|
#ifndef GETTEXT_PACKAGE
|
||||||
#error You must define GETTEXT_PACKAGE before including gi18n-lib.h.
|
#error You must define GETTEXT_PACKAGE before including gi18n-lib.h.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _(String) g_dgettext (GETTEXT_PACKAGE, String)
|
#define _(String) dgettext (GETTEXT_PACKAGE, String)
|
||||||
#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, 0)
|
#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, 0)
|
||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, strlen (Context) + 1)
|
#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, strlen (Context) + 1)
|
||||||
|
204
glib/gi18n.c
204
glib/gi18n.c
@ -1,204 +0,0 @@
|
|||||||
/* GLIB - Library of useful routines for C programming
|
|
||||||
* Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
|
||||||
* file for a list of people on the GLib Team. See the ChangeLog
|
|
||||||
* files for a list of changes. These files are distributed with
|
|
||||||
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gi18n.h"
|
|
||||||
#include "galias.h"
|
|
||||||
#include "gmessages.h"
|
|
||||||
#include "galloca.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
static gboolean should_translate = TRUE;
|
|
||||||
static gboolean do_setlocale = TRUE;
|
|
||||||
static gboolean initialized = FALSE;
|
|
||||||
|
|
||||||
void
|
|
||||||
g_i18n_init (void)
|
|
||||||
{
|
|
||||||
gchar *domain, *default_domain, *locale;
|
|
||||||
|
|
||||||
initialized = TRUE;
|
|
||||||
|
|
||||||
locale = setlocale (LC_ALL, do_setlocale ? "" : NULL);
|
|
||||||
domain = g_strdup (textdomain (NULL));
|
|
||||||
default_domain = g_strdup (textdomain (""));
|
|
||||||
textdomain (domain);
|
|
||||||
|
|
||||||
if (!strcmp (domain, default_domain))
|
|
||||||
{
|
|
||||||
g_warning ("textdomain() must be called before glib i18n initialization");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!*gettext ("") && (!locale || strcmp (locale, "C")))
|
|
||||||
{
|
|
||||||
should_translate = FALSE;
|
|
||||||
g_warning ("No translation is available for the requested locale.");
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_free (domain);
|
|
||||||
g_free (default_domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* g_disable_setlocale:
|
|
||||||
*
|
|
||||||
* Prevents g_i18n_init() from automatically
|
|
||||||
* calling <literal>setlocale (LC_ALL, "")</literal>. You would
|
|
||||||
* want to use this function if you wanted to set the locale for
|
|
||||||
* your program to something other than the user's locale, or if
|
|
||||||
* you wanted to set different values for different locale categories.
|
|
||||||
*
|
|
||||||
* Most programs should not need to call this function.
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
g_disable_setlocale (void)
|
|
||||||
{
|
|
||||||
if (initialized)
|
|
||||||
g_warning ("g_disable_setlocale() must be called before g_i18n_init()");
|
|
||||||
|
|
||||||
do_setlocale = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* g_gettext:
|
|
||||||
* @msgid: message to translate
|
|
||||||
*
|
|
||||||
* This function is a wrapper of gettext() which does not not translate
|
|
||||||
* the message if the application who initialized glib i18n is not translated.
|
|
||||||
*
|
|
||||||
* Applications should normally not use this function directly,
|
|
||||||
* but use the _() macro for translations.
|
|
||||||
*
|
|
||||||
* Returns: The translated string
|
|
||||||
*
|
|
||||||
* Since: 2.16
|
|
||||||
*/
|
|
||||||
const gchar *
|
|
||||||
g_gettext (const gchar *msgid)
|
|
||||||
{
|
|
||||||
if (!initialized)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (!should_translate)
|
|
||||||
return msgid;
|
|
||||||
|
|
||||||
out:
|
|
||||||
return gettext (msgid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* g_dgettext:
|
|
||||||
* @domain: the translation domain to use, or %NULL to use
|
|
||||||
* the domain set with textdomain()
|
|
||||||
* @msgid: message to translate
|
|
||||||
*
|
|
||||||
* This function is a wrapper of dgettext() which does not not translate
|
|
||||||
* the message if the application who initialized glib i18n is not translated.
|
|
||||||
*
|
|
||||||
* Applications should normally not use this function directly,
|
|
||||||
* but use the _() macro for translations.
|
|
||||||
*
|
|
||||||
* Returns: The translated string
|
|
||||||
*
|
|
||||||
* Since: 2.16
|
|
||||||
*/
|
|
||||||
const gchar *
|
|
||||||
g_dgettext (const gchar *domain,
|
|
||||||
const gchar *msgid)
|
|
||||||
{
|
|
||||||
if (!initialized)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (!should_translate)
|
|
||||||
return msgid;
|
|
||||||
|
|
||||||
out:
|
|
||||||
return dgettext (domain, msgid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* g_dpgettext:
|
|
||||||
* @domain: the translation domain to use, or %NULL to use
|
|
||||||
* the domain set with textdomain()
|
|
||||||
* @msgctxtid: a combined message context and message id, separated
|
|
||||||
* by a \004 character
|
|
||||||
* @msgidoffset: the offset of the message id in @msgctxid
|
|
||||||
*
|
|
||||||
* This function is a variant of dgettext() which supports
|
|
||||||
* a disambiguating message context. GNU gettext uses the
|
|
||||||
* '\004' character to separate the message context and
|
|
||||||
* message id in @msgctxtid.
|
|
||||||
* If 0 is passed as @msgidoffset, this function will fall back to
|
|
||||||
* trying to use the deprecated convention of using "|" as a separation
|
|
||||||
* character.
|
|
||||||
*
|
|
||||||
* Applications should normally not use this function directly,
|
|
||||||
* but use the C_() macro for translations with context.
|
|
||||||
*
|
|
||||||
* Returns: The translated string
|
|
||||||
*
|
|
||||||
* Since: 2.16
|
|
||||||
*/
|
|
||||||
const gchar *
|
|
||||||
g_dpgettext (const gchar *domain,
|
|
||||||
const gchar *msgctxtid,
|
|
||||||
gsize msgidoffset)
|
|
||||||
{
|
|
||||||
const gchar *translation;
|
|
||||||
gchar *sep;
|
|
||||||
|
|
||||||
translation = g_dgettext (domain, msgctxtid);
|
|
||||||
|
|
||||||
if (translation == msgctxtid)
|
|
||||||
{
|
|
||||||
if (msgidoffset > 0)
|
|
||||||
return msgctxtid + msgidoffset;
|
|
||||||
|
|
||||||
sep = strchr (msgctxtid, '|');
|
|
||||||
|
|
||||||
if (sep)
|
|
||||||
{
|
|
||||||
/* try with '\004' instead of '|', in case
|
|
||||||
* xgettext -kQ_:1g was used
|
|
||||||
*/
|
|
||||||
gchar *tmp = g_alloca (strlen (msgctxtid) + 1);
|
|
||||||
strcpy (tmp, msgctxtid);
|
|
||||||
tmp[sep - msgctxtid] = '\004';
|
|
||||||
|
|
||||||
translation = g_dgettext (domain, tmp);
|
|
||||||
|
|
||||||
if (translation == tmp)
|
|
||||||
return sep + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return translation;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __G_I18N_C__
|
|
||||||
#include "galiasdef.c"
|
|
20
glib/gi18n.h
20
glib/gi18n.h
@ -24,27 +24,9 @@
|
|||||||
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
|
||||||
#if !defined(__G_I18N_LIB_H__) && !defined(__GLIBINTL_H__)
|
#define _(String) gettext (String)
|
||||||
#define _(String) g_gettext (String)
|
|
||||||
#define Q_(String) g_dpgettext (NULL, String, 0)
|
#define Q_(String) g_dpgettext (NULL, String, 0)
|
||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1)
|
#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1)
|
||||||
#endif
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
G_CONST_RETURN gchar *g_gettext (const gchar *msgid);
|
|
||||||
|
|
||||||
G_CONST_RETURN gchar *g_dgettext (const gchar *domain,
|
|
||||||
const gchar *msgid);
|
|
||||||
|
|
||||||
G_CONST_RETURN gchar *g_dpgettext (const gchar *domain,
|
|
||||||
const gchar *msgctxtid,
|
|
||||||
gsize msgidoffset);
|
|
||||||
|
|
||||||
void g_i18n_init (void);
|
|
||||||
void g_disable_setlocale (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __G_I18N_H__ */
|
#endif /* __G_I18N_H__ */
|
||||||
|
@ -1146,6 +1146,7 @@ g_strdown
|
|||||||
#endif
|
#endif
|
||||||
g_strv_length
|
g_strv_length
|
||||||
g_strip_context
|
g_strip_context
|
||||||
|
g_dpgettext
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1582,16 +1583,6 @@ g_win32_locale_filename_from_utf8
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_HEADER(__G_I18N_H__)
|
|
||||||
#if IN_FILE(__G_I18N_C__)
|
|
||||||
g_i18n_init
|
|
||||||
g_disable_setlocale
|
|
||||||
g_gettext
|
|
||||||
g_dgettext
|
|
||||||
g_dpgettext
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef INCLUDE_VARIABLES
|
#ifdef INCLUDE_VARIABLES
|
||||||
g_ascii_table
|
g_ascii_table
|
||||||
g_utf8_skip
|
g_utf8_skip
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#ifndef __GLIBINTL_H__
|
#ifndef __GLIBINTL_H__
|
||||||
#define __GLIBINTL_H__
|
#define __GLIBINTL_H__
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
|
|
||||||
#ifndef SIZEOF_CHAR
|
#ifndef SIZEOF_CHAR
|
||||||
#error "config.h must be included prior to glibintl.h"
|
#error "config.h must be included prior to glibintl.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2844,5 +2844,66 @@ g_strv_length (gchar **str_array)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_dpgettext:
|
||||||
|
* @domain: the translation domain to use, or %NULL to use
|
||||||
|
* the domain set with textdomain()
|
||||||
|
* @msgctxtid: a combined message context and message id, separated
|
||||||
|
* by a \004 character
|
||||||
|
* @msgidoffset: the offset of the message id in @msgctxid
|
||||||
|
*
|
||||||
|
* This function is a variant of dgettext() which supports
|
||||||
|
* a disambiguating message context. GNU gettext uses the
|
||||||
|
* '\004' character to separate the message context and
|
||||||
|
* message id in @msgctxtid.
|
||||||
|
* If 0 is passed as @msgidoffset, this function will fall back to
|
||||||
|
* trying to use the deprecated convention of using "|" as a separation
|
||||||
|
* character.
|
||||||
|
*
|
||||||
|
* Applications should normally not use this function directly,
|
||||||
|
* but use the C_() macro for translations with context.
|
||||||
|
*
|
||||||
|
* Returns: The translated string
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
g_dpgettext (const gchar *domain,
|
||||||
|
const gchar *msgctxtid,
|
||||||
|
gsize msgidoffset)
|
||||||
|
{
|
||||||
|
const gchar *translation;
|
||||||
|
gchar *sep;
|
||||||
|
|
||||||
|
translation = dgettext (domain, msgctxtid);
|
||||||
|
|
||||||
|
if (translation == msgctxtid)
|
||||||
|
{
|
||||||
|
if (msgidoffset > 0)
|
||||||
|
return msgctxtid + msgidoffset;
|
||||||
|
|
||||||
|
sep = strchr (msgctxtid, '|');
|
||||||
|
|
||||||
|
if (sep)
|
||||||
|
{
|
||||||
|
/* try with '\004' instead of '|', in case
|
||||||
|
* xgettext -kQ_:1g was used
|
||||||
|
*/
|
||||||
|
gchar *tmp = g_alloca (strlen (msgctxtid) + 1);
|
||||||
|
strcpy (tmp, msgctxtid);
|
||||||
|
tmp[sep - msgctxtid] = '\004';
|
||||||
|
|
||||||
|
translation = dgettext (domain, tmp);
|
||||||
|
|
||||||
|
if (translation == tmp)
|
||||||
|
return sep + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define __G_STRFUNCS_C__
|
#define __G_STRFUNCS_C__
|
||||||
#include "galiasdef.c"
|
#include "galiasdef.c"
|
||||||
|
@ -3280,7 +3280,7 @@ glib_gettext (const gchar *str)
|
|||||||
_glib_gettext_initialized = TRUE;
|
_glib_gettext_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_dgettext (GETTEXT_PACKAGE, str);
|
return dgettext (GETTEXT_PACKAGE, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user