libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
gettext.h File Reference
#include <string>
#include <libintl.h>

Go to the source code of this file.

Namespaces

namespace  Nickvision
 
namespace  Nickvision::Localization
 
namespace  Nickvision::Localization::Gettext
 

Macros

#define GETTEXT_CONTEXT_SEPARATOR   "\004"
 
#define _(String)
 
#define _n(String, StringPlural, N)
 
#define _p(Context, String)
 
#define _pn(Context, String, StringPlural, N)
 

Functions

bool Nickvision::Localization::Gettext::init (const std::string &domainName)
 Initializes the gettext system. This function should only be called once, regardless of with different domain names.
 
const std::string & Nickvision::Localization::Gettext::getDomainName ()
 Gets the domain name used for gettext translations.
 
const char * Nickvision::Localization::Gettext::pgettext (const char *context, const char *msg)
 Translates a message for a given context.
 
const char * Nickvision::Localization::Gettext::pngettext (const char *context, const char *msg, const char *msgPlural, unsigned long n)
 Translates a plural message for a given context.
 

Detailed Description

Author
Nicholas Logozzo nlogo.nosp@m.zzo2.nosp@m.25@gm.nosp@m.ail..nosp@m.com

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at https://www.gnu.org/copyleft/gpl.html

DESCRIPTION

Functions for working with gettext (libintl) translations.

Macro Definition Documentation

◆ _

#define _ ( String)
Value:
const std::string & getDomainName()
Gets the domain name used for gettext translations.

◆ _n

#define _n ( String,
StringPlural,
N )
Value:
dngettext(::Nickvision::Localization::Gettext::getDomainName().c_str(), String, StringPlural, static_cast<unsigned long>(N))

◆ _p

#define _p ( Context,
String )
Value:
#define GETTEXT_CONTEXT_SEPARATOR
Definition gettext.h:29
const char * pgettext(const char *context, const char *msg)
Translates a message for a given context.

◆ _pn

#define _pn ( Context,
String,
StringPlural,
N )
Value:
::Nickvision::Localization::Gettext::pngettext(Context GETTEXT_CONTEXT_SEPARATOR String, String, StringPlural, static_cast<unsigned long>(N))
const char * pngettext(const char *context, const char *msg, const char *msgPlural, unsigned long n)
Translates a plural message for a given context.

◆ GETTEXT_CONTEXT_SEPARATOR

#define GETTEXT_CONTEXT_SEPARATOR   "\004"