## Internationalization Internationalization — Internationalization and Localization Support Functions |

## Functions

void | xfce_textdomain ()
gchar * | xfce_get_file_localized ()
gchar * | xfce_get_file_localized_r ()
gchar * | xfce_get_dir_localized ()
gchar * | xfce_get_dir_localized_r ()
gchar * | xfce_get_path_localized ()
guint | xfce_locale_match ()

## Types and Values

#define | XFCE_LOCALE_FULL_MATCH
#define | XFCE_LOCALE_NO_MATCH

## Includes

    #include <libxfce4util/libxfce4util.h>

## Description

Provides functions to aid application developers making their software localizable. It extends the basic internationalization support provided by GLib 2.4 (and newer).

## Functions

### xfce_textdomain ()

    void
    xfce_textdomain (const gchar *package,
                     const gchar *localedir,
                     const gchar *encoding);

Sets up the translations for `package` .

#### Parameters

package | the package name. |
localedir | the `package` s locale directory. |
encoding | the encoding to use the `package` s translations or `NULL` to use "UTF-8". |

### xfce_get_file_localized ()

    gchar *
    xfce_get_file_localized (const gchar *filename);

Checks if theres a version of `filename` which is localized to the current locale. This is done by appending the full locale name to `filename` , separated by a '.'. If theres no file of that name, it retries using the full locale name without the encoding (if any), then without the qualifier (if any) and at last the base locale is tried. If all of those fails, a copy of `filename` is returned.

#### Parameters

filename | name of a file to look for a localized version. |

#### Returns

path of the localized file or copy of `filename` if no such file exists. Returned string should be freed using `g_free()`.

### xfce_get_file_localized_r ()

    gchar *
    xfce_get_file_localized_r (gchar *buffer,
                               gsize length,
                               const gchar *filename);

Similar in functionality to `xfce_get_file_localized()`, but stores the result in `buffer` instead of allocating a new buffer.

#### Parameters

buffer | destination buffer to store the localized filename to. |
length | size of `buffer` in bytes. |
filename | name of a file to look for a localized version. |

#### Returns

pointer to `buffer` or `NULL` on error.

### xfce_get_dir_localized ()

    gchar *
    xfce_get_dir_localized (const gchar *directory);

Similar to `xfce_get_file_localized()`, but works on directory instead of a file.

#### Parameters

directory | directory name to check for a localized variant. |

#### Returns

path of the localized directory name or copy of `directory` if no such directory exists. Returned string should be freed using `g_free()`.

### xfce_get_dir_localized_r ()

    gchar *
    xfce_get_dir_localized_r (gchar *buffer,
                              gsize length,
                              const gchar *directory);

Similar to xfce_get_file_localized_r, but works on directory instead of regular file.

#### Parameters

buffer | destination buffer to store the localized filename to. |
length | size of `buffer` in bytes. |
directory | name of directory to check for localized variant of. |

#### Returns

pointer to `buffer` or `NULL` on error.

### xfce_get_path_localized ()

    gchar *
    xfce_get_path_localized (gchar *dst,
                             gsize size,
                             const gchar *paths,
                             const gchar *filename,
                             GFileTest test);

`paths` is a ':'-separated list of pathnames, with:

- `%F`: the `filename`

- `%L`: the language string, as returned by `setlocale(LC_MESSAGES, NULL)`

- `%l`: the language component of the language string

- `%N`: application name

Example paths: `/usr/local/lib/%L/%F:/usr/local/share/%N/%l/%F`

#### Parameters

dst | destination buffer. |
size | size of `dst` in bytes. |
paths | the path |
filename | the filename |
test | test |

### xfce_locale_match ()

    guint
    xfce_locale_match (const gchar *locale1,
                       const gchar *locale2);

The locale is of the general form LANG_COUNTRY.ENCODING @ MODIFIER, where each of COUNTRY, ENCODING and MODIFIER can be absent.

The match is done by actually removing the rightmost element one by one. This is not entirely according to the freedesktop.org specification, but much easier. Will probably be fixed in the future.

#### Parameters

locale1 | the current locale value as returned by setlocale(LC_MESSAGES,`NULL`). |
locale2 | the locale value to match against. |

#### Returns

an integer value indicating the level of matching, where the constant XFCE_LOCALE_FULL_MATCH indicates a full match and XFCE_LOCALE_NO_MATCH means no match. Every other value indicates a partial match, the higher the value, the better the match. You should not rely on any specific value besides the constants XFCE_LOCALE_FULL_MATCH and XFCE_LOCALE_NO_MATCH, since the range of returned values may change in the future.

Since: 4.2

## Types and Values

### XFCE_LOCALE_FULL_MATCH

    #define XFCE_LOCALE_FULL_MATCH 50

### XFCE_LOCALE_NO_MATCH

    #define XFCE_LOCALE_NO_MATCH    0

## See Also

https://developer.gnome.org/glib/stable/glib-I18N.html