Results 1 to 1 of 1
Hi all,
I wrote simple hello world code using gettext function. My C code is:
Code:
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
char * ...
- 12-24-2010 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 6
gettext rendering problem
Hi all,
I wrote simple hello world code using gettext function. My C code is:
My hello.po file is:Code:#include <libintl.h> #include <locale.h> #include <stdio.h> #include <stdlib.h> int main (void) { char * loc = setlocale (LC_MESSAGES, "tr_TR.UTF-8"); if ( loc == NULL) { perror ("setlocale"); exit (1); } bindtextdomain ("hello", "po"); textdomain ("hello"); printf ("%s\n", loc); printf (gettext("hello world!\n")); exit (0); }
The corresponding po and compiled mo file is in the code directory:Code:msgid "" msgstr "" "Project-Id-Version: hello 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-12-24 22:17+0200\n" "PO-Revision-Date: 2010-12-24 22:17+0200\n" "Last-Translator: artuyild>\n" "Language-Team: Turkish\n" "Language: tr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: hello.c:16 #, c-format msgid "hello world!\n" msgstr "merhaba dünya!\n"
./po/tr_TR.UTF-8/LC_MESSAGES/hello.mo
As you see, I set locale to turkish locale. In my computer, I have turkish locale files when I type locale -a I can see tr_TR.UTF-8 item.
the LANG variable is set to en_US.utf8
When I run the program, text is rendered in the terminal as:
So "dünya" is rendered as "d?nya". "ü" is rendered as question mark.Code:tr_TR.UTF-8 merhaba d?nya!
What can be the problem?


Reply With Quote