~ubuntu-branches/ubuntu/trusty/lifelines/trusty

« back to all changes in this revision

Viewing changes to src/gedlib/llgettext.c

  • Committer: Bazaar Package Importer
  • Author(s): Felipe Augusto van de Wiel (faw)
  • Date: 2007-08-14 00:02:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.4 gutsy)
  • Revision ID: james.westby@ubuntu.com-20070814000204-mpv5faygl0dgq3qi
Tags: 3.0.61-1
* New upstream release. (Closes: #387856).
* Fixing documentation build problems also fixes FTBFS if built twice in a
  row. (Closes: #424543).
* Adding lynx as a build dependency. This is necessary to generate txt files
  from html, discovered while fixing #424543.
* Upstream fix: charset for gedcom file in unicode. (Closes: #396206).
* Upstream fim: updating documentation about desc-tex2. (Closes: #405501).
* Bumping Standards-Version to 3.7.2 without package changes.
* Dropping local debian patches added upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
#include "llstdlib.h"
13
13
#include "gedcom.h"
 
14
#include "gedcomi.h"
14
15
#include "codesets.h"
15
16
#include "lloptions.h"
16
17
#include "zstr.h"
20
21
 * local variables
21
22
 *********************************************/
22
23
 
 
24
static TABLE gt_localeDirs = NULL; /* most recent */ /* leaks */
23
25
static STRING gt_codeset = 0; /* codeset passed to bind_textdomain_codeset */
 
26
static STRING gt_defLocaleDir = 0; /* compiled default */ /* leak */
24
27
 
25
28
/*********************************************
26
29
 * local & exported function definitions
28
31
 *********************************************/
29
32
 
30
33
/*==================================================
 
34
 * llgettext_set_default_localedir -- save LOCALEDIR
 
35
 *================================================*/
 
36
void
 
37
llgettext_set_default_localedir (CNSTRING localeDir)
 
38
{
 
39
        strupdate(&gt_defLocaleDir, localeDir);
 
40
}
 
41
/*==================================================
31
42
 * llgettext_init -- initialize gettext with initially
32
 
 *  desired codeset
 
43
 * desired codeset. This may be changed later by user
 
44
 * options, but  this is initial best guess.
 
45
 *  domain:  [IN]  package domain (eg, "lifelines")
 
46
 *  codeset: [IN]  codeset to use
33
47
 *================================================*/
34
48
void
35
49
llgettext_init (CNSTRING domain, CNSTRING codeset)
36
50
{
37
51
#if ENABLE_NLS
38
 
        STRING e;
39
 
 
40
52
        /* until we have an internal codeset (which is until we open a database)
41
53
        we want output in display codeset */
42
 
        set_gettext_codeset(PACKAGE, gui_codeset_out);
 
54
        set_gettext_codeset(domain, codeset);
43
55
 
44
 
        /* allow run-time specification of locale directory */
45
 
        /* (LOCALEDIR is compile-time) */
46
 
        e = getlloptstr("LocaleDir", "");
47
 
        if (e && *e) {
48
 
                bindtextdomain(PACKAGE, e);
49
 
                locales_notify_language_change(); /* TODO: is this necessary ? 2002-09-29, Perry */
50
 
        }
 
56
        update_textdomain_localedir(domain, "Ui");
51
57
 
52
58
#else /* ENABLE_NLS */
53
59
        domain = domain;
54
60
        codeset = codeset;
55
61
#endif /* ENABLE_NLS */
56
62
}
 
63
/*==================================================
 
64
 * update_textdomain_localedir --
 
65
 *  call bindtextdomain with current localedir
 
66
 *  domain:  [IN] package domain (eg, "lifelines")
 
67
 *  prefix:  [IN] "Ui" or "Rpt"
 
68
 *================================================*/
 
69
void
 
70
update_textdomain_localedir (CNSTRING domain, CNSTRING prefix)
 
71
{
 
72
        STRING newLocaleDir = 0;
 
73
        char keyname[30] = ""; /* eg, "UiLocaleDir" */
 
74
        /* allow run-time specification of locale directory */
 
75
 
 
76
        /* Default to compile-time specified (LOCALEDIR) */
 
77
        newLocaleDir = gt_defLocaleDir;
 
78
 
 
79
        /* Check for config setting for LocaleDir */
 
80
        newLocaleDir = getlloptstr("LocaleDir", newLocaleDir);
 
81
 
 
82
        /* Check for Ui or Rpt specific setting, eg, UiLocaleDir */
 
83
        if (prefix && prefix[0]) {
 
84
                snprintf(keyname, sizeof(keyname), "%sLocaleDir", prefix);
 
85
                newLocaleDir = getlloptstr(keyname, newLocaleDir);
 
86
        }
 
87
 
 
88
        if (newLocaleDir) {
 
89
                /* ll_bindtextdomain is caching; it will only submit
 
90
                real changes to gettext version */
 
91
                ll_bindtextdomain(domain, newLocaleDir);
 
92
        }
 
93
}
 
94
/*=================================
 
95
 * ll_bindtextdomain -- interceptor for bindtextdomain calls
 
96
 *  to send ui callbacks
 
97
 *===============================*/
 
98
void
 
99
ll_bindtextdomain (CNSTRING domain, CNSTRING localeDir)
 
100
{
 
101
#if ENABLE_NLS
 
102
        STRING oldLocaleDir = 0;
 
103
 
 
104
        if (!gt_localeDirs) {
 
105
                gt_localeDirs = create_table_str();
 
106
        }
 
107
        /* skip if already set */
 
108
        oldLocaleDir = valueof_str(gt_localeDirs, domain);
 
109
        if (eqstr_ex(oldLocaleDir, localeDir))
 
110
                return;
 
111
        insert_table_str(gt_localeDirs, domain, localeDir);
 
112
 
 
113
        bindtextdomain(domain, localeDir);
 
114
        locales_notify_language_change();
 
115
#endif /* ENABLE_NLS */
 
116
}
57
117
/*=================================
58
118
 * init_win32_gettext_shim -- 
59
119
 *  Handle user-specified iconv dll path
70
130
        {
71
131
                if (intlshim_set_property("dll_path", e))
72
132
                {
73
 
                        bindtextdomain(PACKAGE, LOCALEDIR);
 
133
                        /* clear cache of bindtextdomain calls */
 
134
                        if (gt_localeDirs) {
 
135
                                destroy_table(gt_localeDirs);
 
136
                                gt_localeDirs = 0;
 
137
                        }
 
138
                        ll_bindtextdomain(PACKAGE, LOCALEDIR);
74
139
                        textdomain(PACKAGE);
75
140
                }
76
141
                /* tell gettext where to find iconv */