Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
gettext.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * see git history
7 * Patrick Storz <eduard.braun2@gmx.de>
8 *
9 * Copyright (C) 2018 Authors
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#ifdef HAVE_CONFIG_H
14# include "config.h" // only include where actually required!
15#endif
16
17#ifdef _WIN32
18#include <windows.h>
19#endif
20
21#include "path-prefix.h"
22
23#include <string>
24#include <glibmm.h>
25#include <glibmm/i18n.h>
26
27namespace Inkscape {
28
31 auto localepath = Glib::getenv("INKSCAPE_LOCALEDIR");
32
33 if (localepath.empty()) {
34 localepath = Glib::build_filename(Glib::path_get_dirname(get_inkscape_datadir()), PACKAGE_LOCALE_DIR);
35 }
36
37 if (!Glib::file_test(localepath, Glib::FileTest::IS_DIR)) {
38 localepath = PACKAGE_LOCALE_DIR_ABSOLUTE;
39 }
40
41#ifdef _WIN32
42 // obtain short path, bindtextdomain doesn't understand UTF-8
43 auto shortlocalepath = g_win32_locale_filename_from_utf8(localepath.c_str());
44 localepath = shortlocalepath;
45 g_free(shortlocalepath);
46#endif
47
48 bindtextdomain(GETTEXT_PACKAGE, localepath.c_str());
49
50 // common setup
51 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
52 textdomain(GETTEXT_PACKAGE);
53}
54
57 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
58}
59
68#ifdef _WIN32
69 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
70#else
71 std::string charset;
72 Glib::get_charset(charset);
73 bind_textdomain_codeset(GETTEXT_PACKAGE, charset.c_str());
74#endif
75}
76
77}
78
79
80/*
81 Local Variables:
82 mode:c++
83 c-file-style:"stroustrup"
84 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
85 indent-tabs-mode:nil
86 fill-column:99
87 End:
88*/
89// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
Helper class to stream background task notifications as a series of messages.
void bind_textdomain_codeset_utf8()
set gettext codeset to UTF8
Definition gettext.cpp:56
void bind_textdomain_codeset_console()
set gettext codeset to codeset of the system console
Definition gettext.cpp:67
void initialize_gettext()
does all required gettext initialization and takes care of the respective locale directory paths
Definition gettext.cpp:30
char const * get_inkscape_datadir()
Determine the location of the Inkscape data directory (typically the share/ folder from where Inkscap...
TODO: insert short description here.