Common Desktop Environment: Internationalization Programmer's Guide

Setting a Compound String Programmatically

An application can set this resource programmatically by creating the compound string using the XmStringCreateLocalized() compound string convenience function.

This function creates a compound string in the encoding of the current locale and automatically sets the font list entry tag to XmFONTLIST_DEFAULT_TAG.

The following code segment shows one way to set the XmNlabelString resource for a push button using a program.

#include <nl_types.h>  
Widget		button;  
Args		args[10];  
int		n; 
 XmString button_label;  
nl_msg my_catd;  
(void)XtSetLanguageProc(NULL,NULL,NULL);
  		.
  		.  
button_label = XmStringCreateLocalized (catgets(my_catd, 1, 1,
  		 	"default label"),
  			XmFONTLIST_DEFAULT_TAG);   

/* Create an argument list for the button */  
n = 0;  
XtSetArg (args[n], XmNlabelString, button_label); n++;   

/* Create and manage the button */  
button = XmCreatePushButton (toplevel, "button", args, n);  
XtManageChild (button);  
XmStringFree (button_label);