Blame view

libmailutils/nls.c 1.49 KB
Wojciech Polak authored
1
/* GNU Mailutils -- a suite of utilities for electronic mail
2 3
   Copyright (C) 2002, 2006, 2007, 2008, 2010 Free Software Foundation,
   Inc.
Wojciech Polak authored
4

5 6 7
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
8
   version 3 of the License, or (at your option) any later version.
Wojciech Polak authored
9

10
   This library is distributed in the hope that it will be useful,
Wojciech Polak authored
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.
Wojciech Polak authored
14

15 16 17 18
   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA */
Wojciech Polak authored
19 20 21 22 23

#if HAVE_CONFIG_H
# include <config.h>
#endif

Sergey Poznyakoff authored
24
#include <stdlib.h>
Wojciech Polak authored
25
#include <mailutils/nls.h>
26
#include <locale.h>
Wojciech Polak authored
27 28 29

/* Initialize Native Language Support */

30 31 32 33 34 35 36 37 38 39
char *mu_locale_set;

#ifndef HAVE_SETLOCALE
# define setlocale(c,s) NULL
#endif

/* Set locale via LC_ALL.  */
char *
mu_set_locale (const char *locale)
{
Sergey Poznyakoff authored
40
#if defined HAVE_SETLOCALE
41 42 43 44 45 46 47 48 49 50 51 52 53
  return setlocale (LC_ALL, locale);
#else
  return NULL;
#endif
}

void
mu_restore_locale (void)
{
  if (mu_locale_set)
    mu_set_locale (mu_locale_set);
}

Wojciech Polak authored
54 55 56 57
void
mu_init_nls (void)
{
#ifdef ENABLE_NLS
58 59
  mu_locale_set = mu_set_locale ("");
  bindtextdomain (PACKAGE, LOCALEDIR);
Wojciech Polak authored
60 61 62
#endif /* ENABLE_NLS */
}