LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2008, 04:59 PM   #1
iusegnu
LQ Newbie
 
Registered: Apr 2008
Posts: 3

Rep: Reputation: 0
Using Gettext with anjuta


Hi.
I'm trying to learn writing multi-language programs using gettext.
Without any IDE, I can do this using GNU Build System (Autotools) and gettext. But with Anjuta I couldn't find how to do this.

My question is:
In Anjuta (ver: 2.2.3) When I create a generic (console) project (with internationalization support), a simple "hello world" application comes up. After this point, what should I do to make this program support any second language?
(I didn't see any menu option in Anjuta IDE and didn't find any document about it).

Thanks...
 
Old 08-31-2008, 04:51 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You need to include libintl.h, initialize language domain and mark all your messages as possible to translate.

The general program template looks like (from: http://www.gnu.org/software/gettext/manual/gettext.html, section 4):
Code:
     int
     main (int argc, char *argv[])
     {
       ...
       setlocale (LC_ALL, "");
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);
       ...
     }
where PACKAGE may be the name of your program and LOCALEDIR points to the place the translations will be installed (for development it may be your project directory, but check if Anjuta has not defined them already for you).

Then, marking the strings. Usually such define is used:
#define _(String) gettext (String)

That gives you a macro, which is used this way:
printf (_("Translated text"));
You simply put all strings (visible ones) in _() macro.

The rest (extracting strings, building .po and .mo files) should be done by the Makefile. I recommend gtetext manual in case of problems (link was above).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Probleme with GetText seb2020 Linux From Scratch 0 08-26-2007 06:57 AM
perl-gettext justwantin Slackware 2 05-08-2007 06:10 PM
gettext and localization mifi Linux - Software 0 03-24-2006 07:02 AM
Help with Gettext Snouser Linux - Software 2 03-02-2006 11:41 PM
php + gettext Ateo Linux - General 0 11-09-2005 11:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration