Changeset 59156


Ignore:
Timestamp:
Mar 1, 2014, 9:55:31 AM (10 years ago)
Author:
marisn
Message:

Introduce ngettext support and a new macro _n for it

Location:
grass/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/include/defs/glocale.h

    r57238 r59156  
    44extern void G_init_locale(void);
    55extern char *G_gettext(const char *, const char *) __attribute__((format_arg (2)));
     6extern char *G_ngettext(const char *, const char *, const char *, unsigned long int) __attribute__((format_arg (2), format_arg (3)));
    67
    78#endif
  • grass/trunk/include/glocale.h

    r49183 r59156  
    99#include <libintl.h>
    1010#define _(str) G_gettext(PACKAGE,(str))
     11#define _n(strs,strp,num) G_ngettext(PACKAGE,(strs),(strp),num)
    1112#else
    1213#define _(str) (str)
  • grass/trunk/lib/gis/locale.c

    r34695 r59156  
    7171#endif
    7272}
     73
     74/**
     75 * \brief Gets localized text with correct plural forms.
     76 *
     77 * \param[in] package
     78 * \param[in] msgids A singular version of string
     79 * \param[in] msgidp A plural version of string
     80 * \param[in] n The number
     81 * \retval char * Pointer to string
     82 */
     83
     84char *G_ngettext(const char *package, const char *msgids, const char *msgidp, unsigned long int n)
     85{
     86#if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
     87    G_init_locale();
     88
     89    return dngettext(package, msgids, msgidp, n);
     90#else
     91    return n == 1 ? (char *)msgids : (char *)msgidp;
     92#endif
     93}
Note: See TracChangeset for help on using the changeset viewer.