Operating System - HP-UX
1753912 Members
8513 Online
108810 Solutions
New Discussion юеВ

NLS Implementation Question

 
Cathleen Einberger
New Member

NLS Implementation Question

Currently my company has software that is using NLS, the code is written in C. We have an installation that is running in English, German, and Hungarian. At times, text will be displayed in the wrong language.

What I am wondering is whether we are using the NLS facility correctly. The message catalogs are stored in different directories, the catalog files themselves have the same name. The software runs on radio frequency equipment, so the radios will "log in" and start a session on the HP. Note that the user is not "really" logging into the HP.

The software will then use putenv to set LANG and LC_ALL to the user's language. When a call is made to get a translated string, the code will check whether the catalog has already been opened. This is done using the catopen command. The full path is not passed in, just the file name. If the file is opened, the name is stored in a C array with the descriptor that is returned. The next time that a string is needed, this array is checked to see if the catalog is already opened.

Does anyone see a problem with the way this is set up? The site reports that messages will be displayed in any of the 3 languages within the same session.

Any help would be appreciated!

Thanks,

Cathy
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: NLS Implementation Question

Hi Cathleen:

Yes, you appear to be using the LANG env variable correctly if in your catopen() call oflag is zero. The fact that you say it sometimes works and sometimes doesn't points me down another trail. The interesting point is that if for some reason the NLSPATH is invalid, the system reverts to default values.
I have two theories: 1) Your putenv() string points to an auto storage specified string rather than a static or global storage specified string. If the contents of the stack are disturbed, your env vars are garbage. 2) You may be doing an exec() within your code which invalidates the catopen().

Hope this helps, Clay
If it ain't broke, I can fix that.
Cathleen Einberger
New Member

Re: NLS Implementation Question

Thanks Clay for your quick reply!

The code has a login function that sets the NLS environment variables. It uses a pointer of type char * and mallocs space for it, then uses it for the putenv.

Do you see this as a problem?

Thanks,

Cathy
A. Clay Stephenson
Acclaimed Contributor

Re: NLS Implementation Question

Hi Cathleen,

I think we're on the right track. If I understand your response, you've almost done it correctly. Change the char *ptr to static char *ptr within your login function. That way the value remains defined after exiting the login function.



If it ain't broke, I can fix that.