libzypp  13.10.6
Gettext.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 extern "C" {
17 #include <libintl.h>
18 }
19 
20 #include "zypp/base/Gettext.h"
21 
23 namespace zypp
24 {
25  namespace gettext
27  {
28 
30  // TEXTDOMAIN and LOCALEDIR must be provided via config.h
31  // or at compile time using -D.
33 
34  inline void assertInit()
35  {
36  static bool initialized = false;
37  if ( ! initialized )
38  {
39  ::bindtextdomain( TEXTDOMAIN, LOCALEDIR );
40  ::bind_textdomain_codeset( TEXTDOMAIN, "UTF-8" );
41  initialized = true;
42  }
43  }
44 
45  const char * dgettext( const char * msgid )
46  {
47  assertInit();
48  return ::dgettext( TEXTDOMAIN, msgid );
49  }
50 
51  const char * dngettext( const char * msgid1, const char * msgid2,
52  unsigned long n )
53  {
54  assertInit();
55  return ::dngettext( TEXTDOMAIN, msgid1, msgid2, n );
56  }
57 
59  } // namespace gettext
62 } // namespace zypp
Interface to gettext.
const char * dgettext(const char *msgid)
Return translated text.
Definition: Gettext.cc:45
const char * dngettext(const char *msgid1, const char *msgid2, unsigned long n)
Return translated text (plural form).
Definition: Gettext.cc:51
void assertInit()
Definition: Gettext.cc:34