Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# i18n.hh File Reference

A C++ gettext wrapper for internationalization and localiztion. More...

`#include <xfc/utfstring.hh>`

## Namespaces

- namespace Xfc
- namespace Xfc::i18n

## GetText Methods

- const char * _ (const String &str)
    Convenient wrapper for GNU gettext.
- const char * _ (const String &str, const char *domain)
    Convenient wrapper for GNU dgettext.

## Defines

- #define N_(str) (str)
    Macro for No-op i18n marker.

## Functions

- const char * set_text_domain (const char *domain)
    Change or query the current status of the current global domain of the LC_MESSAGE category.
- const char * set_text_domain_dir (const char *domain, const char *dir)
    Binds the given domain to a file in the specified directory dir (see gettext documentation to find out this file is determined).

## Detailed Description

A C++ gettext wrapper for internationalization and localiztion.

Provides convenient C++ wrapper methods for the various gettext functions.

## Define Documentation

#define N_ | ( | str |  | ) | (str)

| Macro for No-op i18n marker. Unfortunately there's no way to make this a function, since the whole point is to have a way to mark text for translation in contexts where a function call is not permitted. You can #define XFC_NO_INTL_NOOP_MARKER to get rid of this macro.

## Function Documentation

const char* _ | ( | const String & | str,
|  | const char * | domain
| ) |

Convenient wrapper for GNU dgettext.

Parameters:

  | str | A String to be passed to dgettext().
  | domain | The name of translation domain; will always be a string literal.

Returns:
  The translation of str if it's available in domain.

GNU gettext does two things. First, it marks a string as translable so xgettext() will find it when it scans your sources. The second thing it does is actually return the translated string. If no translation of str is available the str itself is returned. Libraries must specify the domain because the global domain is reserved for use by applications. Libraries use this method instead of defining a _ macro that calls dgettext(). When you run xgettext() don't forget to specify the '--keyword=_' option. This option tells xgettext that translatable strings are marked with an underscore instead of the word gettext.

const char* _ | ( | const String & | str | ) |

Convenient wrapper for GNU gettext.

Parameters:

  | str | A String to be passed to gettext().

Returns:
  The translation of str if it's available in the current domain.

GNU gettext does two things. First, it marks a string as translable so xgettext() will find it when it scans your sources. The second thing it does is actually return the translated string. If no translation of str is available the str itself is returned. Applications should use this method instead of defining a _ macro that calls gettext(). When you run xgettext() don't forget to specify the '--keyword=_' option. This option tells xgettext that translatable strings are marked with an underscore instead of the word gettext.

const char* set_text_domain | ( | const char * | domain | ) |

Change or query the current status of the current global domain of the LC_MESSAGE category.

Parameters:

  | domain | The name of translation domain (must be legal filename characters).

Returns:
  A domain name (see explanation below).

If the domain is null, the function returns the current value. If no value has been set before, the name of the default domain is returned: messages. It is important to note that no checks of the availability are made. If the name is not available no translations will be provided. The return string must not be freed.

const char* set_text_domain_dir | ( | const char * | domain,
|  | const char * | dir
| ) |

Binds the given domain to a file in the specified directory dir (see gettext documentation to find out this file is determined).

Parameters:

  | domain | The translation domain.
  | dir | The directory name.

Returns:
  A directory name (see expalantion below).

If domain is null nothing happens and a null pointer is returned. If dir is null the directory associated with domain is returned. It is important to remember that relative path names for dir can be trouble. Since the path is always computed relative to the current directory different results will occur when the program executes a chdir command. Relative paths should always be avoided to avoid dependencies and unreliabilities. The return string must not be freed.

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3