[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Can't make gettext hello world work
From: |
Stephen Kelly |
Subject: |
Can't make gettext hello world work |
Date: |
Wed, 03 Nov 2010 23:48:35 +0100 |
User-agent: |
KNode/4.3.2 |
Hi,
When I execute the following, my hello world text is not translated. What am
I doing wrong? Do I need something set up or installed before I can test the
de_DE locale?
Thanks,
Steve.
kde-devel@bishop:~/kde/src/playground/gettext_test$ vi main.cpp
kde-devel@bishop:~/kde/src/playground/gettext_test$ g++ -o main main.cpp
kde-devel@bishop:~/kde/src/playground/gettext_test$ ./main
Hello World
kde-devel@bishop:~/kde/src/playground/gettext_test$ cat main.cpp
#include<libintl.h>
#include<locale.h>
#include<stdio.h>
int main(int argc, char **argv)
{
setlocale(LC_ALL, "");
char *btd = bindtextdomain("i18n", "/home/kde-
devel/kde/src/playground/gettext_test");
char *td = textdomain("i18n");
printf(gettext("Hello World\n"));
return 0;
}
kde-devel@bishop:~/kde/src/playground/gettext_test$ mkdir -p
de_DE/LC_MESSAGES
kde-devel@bishop:~/kde/src/playground/gettext_test$ xgettext -d i18n -o
i18n.pot -s main.cpp
kde-devel@bishop:~/kde/src/playground/gettext_test$ cp i18n.pot de_DE.po
kde-devel@bishop:~/kde/src/playground/gettext_test$ vi de_DE.po
kde-devel@bishop:~/kde/src/playground/gettext_test$ cat de_DE.po
# 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"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-11-03 23:41+0100\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"
#: main.cpp:14
#, c-format
msgid "Hello World\n"
msgstr "Hallo, Welt\n"
kde-devel@bishop:~/kde/src/playground/gettext_test$ msgfmt de_DE.po -o
de_DE/LC_MESSAGES/i18n.mo
de_DE.po: warning: Charset "CHARSET" is not a portable encoding name.
Message conversion to user's charset might not work.
kde-devel@bishop:~/kde/src/playground/gettext_test$ LANG=de_DE ./main
Hello World
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Can't make gettext hello world work,
Stephen Kelly <=