GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Setting language environment 'export LANG'

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
RamDas
Familiar Face


Joined: 07 Apr 2008
Posts: 7

PostPosted: Thu Apr 10, 2008 9:17 am    Post subject: Setting language environment 'export LANG' Reply with quote

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: (C)
1
2
3
4

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
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 376
Location: State College, Pennsylvania

PostPosted: Fri Apr 11, 2008 1:37 pm    Post subject: Reply with quote

You can use GLib's g_setenv() and g_getenv() functions to set and retrieve environment variables on both platforms.
Back to top
RamDas
Familiar Face


Joined: 07 Apr 2008
Posts: 7

PostPosted: Fri Apr 11, 2008 4:30 pm    Post subject: Reply with quote

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: (C)
1
2
3
4
5
6
7
8
9
  . . .
#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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP