~marcustomlinson/unity-scopes-shell/lp-1552082

« back to all changes in this revision

Viewing changes to src/Unity/localization.h

  • Committer: Marcus Tomlinson
  • Date: 2015-02-03 07:32:37 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: marcus.tomlinson@canonical.com-20150203073237-l48gnmhn87e4idsm
Added localization

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
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, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors:
 
17
 *  Marcus Tomlinson <marcus.tomlinson@canonical.com>
 
18
 */
 
19
 
 
20
#ifndef LOCALIZATION_H
 
21
#define LOCALIZATION_H
 
22
 
 
23
#include <libintl.h>
 
24
#include <string>
 
25
 
 
26
inline char * _(const char *__msgid) {
 
27
    return dgettext(GETTEXT_PACKAGE, __msgid);
 
28
}
 
29
 
 
30
inline std::string _(const char *__msgid1, const char *__msgid2,
 
31
                     unsigned long int __n) {
 
32
    char buffer [256];
 
33
    if (snprintf ( buffer, 256, dngettext(GETTEXT_PACKAGE, __msgid1, __msgid2, __n), __n ) >= 0) {
 
34
        return buffer;
 
35
    } else {
 
36
        return std::string();
 
37
    }
 
38
}
 
39
 
 
40
#endif
 
41
 
 
42