#include <locale.h>
#include <libintl.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <monetary.h>
#define LOCALEDIR "/usr/share/locale"
#define PACKAGE "lc_example"
#define BUF 80
#define _(str) gettext(str)
void init() {
setlocale(LC_ALL,"");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
}
void invite() {
printf(_("Hello!\n"));
}
void lc_collate() {
#define N 5
char *words[] = {"plaňka", "pláně", "Plášil", "cikáda", "chroust"};
char *p;
int i,j;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++) {
if (strcoll(words[i],words[j]) < 0) {
p = words[i];
words[i] = words[j];
words[j] = p;
}
}
printf(_("Sorted words:"));
for (i = 0; i < N; i++)
printf(" %s", words[i]);
printf("\n");
}
void lc_time() {
char buf[BUF];
time_t t = time(NULL);
strftime(buf, BUF, "%A", localtime(&t));
printf(_("%s - I hate it!\n"), buf);
}
výheň