~ubuntu-branches/ubuntu/precise/tmispell-voikko/precise

« back to all changes in this revision

Viewing changes to src/i18n.cc

  • Committer: Bazaar Package Importer
  • Author(s): Timo Jyrinki
  • Date: 2006-10-18 20:04:10 UTC
  • Revision ID: james.westby@ubuntu.com-20061018200410-zd4fwc1xwkclmb51
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) Pauli Virtanen
 
2
 *
 
3
 * This program is free software; you can redistribute it and/or
 
4
 * modify it under the terms of the GNU General Public License
 
5
 * as published by the Free Software Foundation; either version 2
 
6
 * of the License, or (at your option) any later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program; if not, write to the Free Software
 
15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
16
 *********************************************************************************/
 
17
 
 
18
/**
 
19
 * @file i18n.cc
 
20
 * @author Pauli Virtanen
 
21
 *
 
22
 * Localization etc.
 
23
 */
 
24
#include <locale.h>
 
25
 
 
26
#include "config.hh"
 
27
#include "i18n.hh"
 
28
 
 
29
#ifdef ENABLE_NLS
 
30
 
 
31
#  include <libintl.h>
 
32
 
 
33
char* _(char const* str)
 
34
{
 
35
        if (str && str[0] != '\0')
 
36
                return dgettext(PACKAGE, str);
 
37
        else
 
38
                return "";
 
39
}
 
40
 
 
41
std::string _(std::string const& str)
 
42
{
 
43
        if (!str.empty())
 
44
                return std::string(dgettext(PACKAGE, str.c_str()));
 
45
        else
 
46
                return std::string();
 
47
}
 
48
 
 
49
void locale_init()
 
50
{
 
51
        setlocale(LC_ALL, "");
 
52
 
 
53
        bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
 
54
        textdomain(PACKAGE);
 
55
}
 
56
 
 
57
#else // ENABLE_NLS
 
58
 
 
59
void locale_init()
 
60
{
 
61
}
 
62
 
 
63
#endif