GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 16, 2014 7:25 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Setting language environment 'export LANG'
PostPosted: Thu Apr 10, 2008 9:17 am 
Offline
Familiar Face

Joined: Mon Apr 07, 2008 8:33 pm
Posts: 11
Hello,

I need help on setting a custom Language environment when an application start. I can do through adding the following line in the beginning of a shell script in the Linux before starting the application. It works. Great.

example:
Code:
export LANG=hi_IN.UTF-8
gedit


This will start Localized Hindi( Indian Language) version of the 'gedit', if the Hindi language pack and localized version of 'gedit' installed. But rest of the all applications and desktop will remain in English as my default language setting is English.

My Problem
In addition to GNOME desktop global language settings, I have a custom language setting in my application. Settings are saved in a configuration file. When the application start the application will read the language value from the configuration file and set the environment for that language. So that my localized version of the application will run in the specific language, but rest of them keep the desktops default language. At present , I am achieving this goal by modifying the value in the shell script in Linux and '.bat' file in Windows through my application.

My question is how to code to do 'export LANG=xxx' in C language without using shell script and use that environment when the program start. I don't want use 'VTE Terminal Widget'. I am trying to build the application using minimum GTK+ libraries that will run on both Windows and Linux.

Thanks.
Ram Das


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 1:37 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You can use GLib's g_setenv() and g_getenv() functions to set and retrieve environment variables on both platforms.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 4:30 pm 
Offline
Familiar Face

Joined: Mon Apr 07, 2008 8:33 pm
Posts: 11
Hello Andrew,
Quote:
You can use GLib's g_setenv() and g_getenv() functions to set and retrieve environment variables on both platforms.

Yes! thats works!

Code:
  . . .
#ifdef ENABLE_NLS
  test = g_setenv ("LANG", "hi_IN.UTF-8", TRUE);
  . . .
  . . .   
#endif

gtk_init (&argc, &argv);
  . . .

I can see the point of important where you have included a chapter "Using GLib" in your book " Foundations of GTK+ Development". Thank you very much for your help.

Ram Das


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group