[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gettext



Bonjour la liste !

Je voudrais creer un programme multilingue (C C++).... apres recherche sur google, je m'apercois que gettext est fait pour moi, du moins c'est ce que je pense !

Mais comment utiliser gettext, je trouve pas un exemple simple du style "hello world" convertie en francais ou espagnol !

Apparement i lfaut creer un fichier po puis parametrer des variables !

Merci de votre aide !

David

Ok je viens de trouver un exemple mais qui marche pas chez moi......

Voici le source du prog :
#include <stdio.h>
#include <libintl.h>

int main() {
   textdomain("essai.po");
   printf( gettext("Hello, world !\n") );
   return 0;
}

la compil : gcc -Wall -o essai essai.c

----------------------------------------------------------------------------------------------------------
je genere le fichier po avec : xgettext -a -d hello-world -k_ -s hello.c

voici le contenu du fichier po mis a jour :

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2003-06-06 20:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: essai.c:11
msgid "Hello, world !\n"
msgstr "Bonjour, monde !\n"

#: essai.c:8
msgid "hello-world"
msgstr "bonjour-monde"
----------------------------------------------------------------------------------------------------------

et voici les variables du fichier /etc/profile
LANG=fr_FR
LC_NUMERIC=C
export LANG
export LC_NUMERIC

merci de m'aider, le prog affiche toujours hello world au lieu de bonjour monde....

snif :(

--
+------------------------------+
|  David CABATON alias Obelix  |
+------------------------------+
|                              |
|    cabaton_david@yahoo.fr    |
|                              |
| Student in computer sciences |
|                              |
|     GPG keys: 0x6BBB38E3     |
|                              |
+------------------------------+




Reply to: