/* Test multilanguage support */ #include #include #include "lang.h" void *menu; char **strs; /* All strings of the program */ void __CDECL MenuInfo( WINDOW *win, int item, int title) { void *dial; int ind; dial = dfrm_create( 10, TYPE_NORMAL); ind = dfrm_new_label( dial, TYPE_LABEL, strs[D0_LABEL0] ); dfrm_add( dial, ROOT, ind, -1, -2, DIR_VERT); dfrm_align( dial, ind, DIR_HORI, ALIGN_CENTER); ind = dfrm_new_label( dial, TYPE_LABEL, strs[D0_LABEL1] ); dfrm_add( dial, ROOT, ind, -1, 0, DIR_VERT); dfrm_align( dial, ind, DIR_HORI, ALIGN_CENTER); ind = dfrm_new_button( dial, TYPE_DBUT, strs[D0_OK] ); dfrm_add( dial, ROOT, ind, -1, -2, DIR_VERT); dfrm_align( dial, ind, DIR_HORI, ALIGN_CENTER); dfrm_repack( dial); dfrm_modal( dial, strs[D0_TITLE]); FormWindDo( MU_MESAG); FormWindEnd(); MenuTnormal( NULL, title, 1); } void __CDECL MenuQuit( WINDOW *win, int item, int title) { ApplWrite( _AESapid, AP_TERM, 0, 0, 0, 0, 0); MenuTnormal( win, title, 1); } void __CDECL MenuEnglish( WINDOW *win, int item, int title) { void BuildMenu(void); char **_strs = dfrm_load_str( "lang.en"); if( _strs) { dfrm_free_str( strs); menu_bar( dfrm_tree( menu), 0); dfrm_free_str( strs); strs = _strs; BuildMenu(); } else { FormAlert ( 1, "[1][File \"lang.en\" not found][END]"); MenuTnormal( win, title, 1); } } void __CDECL MenuFrench( WINDOW *dummy, int item, int type, int title) { void BuildMenu(void); char **_strs = dfrm_load_str( "lang.fr"); if( _strs) { dfrm_free_str( strs); menu_bar( dfrm_tree( menu), 0); dfrm_free_str( strs); strs = _strs; BuildMenu(); } else { FormAlert ( 1, "[1][File \"lang.fr\" not found][END]"); MenuTnormal( NULL, title, 1); } } void BuildMenu(void) { int ind, pind; menu = dfrm_create( 30, TYPE_MENU); /* Create a minimal desktop menu structure */ ind = dfrm_new_dmenu( menu, strs[M0_DESK], strs[M0_INFO]); dfrm_attach( menu, ind, BIND_FUNC, MenuInfo); /* Other menu items */ pind = dfrm_add_menu( menu, strs[M0_FILE]); ind = dfrm_new_label( menu, TYPE_MITEM, strs[M0_QUIT]); dfrm_add( menu, pind, ind, 0, 0, DIR_VERT); dfrm_attach( menu, ind, BIND_FUNC, MenuQuit); /* Other menu items */ pind = dfrm_add_menu( menu, strs[M0_LANG]); ind = dfrm_new_label( menu, TYPE_MITEM, strs[M0_FR]); dfrm_align( menu, ind, DIR_HORI, ALIGN_JUSTIFY); dfrm_add( menu, pind, ind, 0, 0, DIR_VERT); dfrm_attach( menu, ind, BIND_FUNC, MenuFrench); ind = dfrm_new_label( menu, TYPE_MITEM, strs[M0_EN]); dfrm_align( menu, ind, DIR_HORI, ALIGN_JUSTIFY); dfrm_add( menu, pind, ind, 0, 0, DIR_VERT); dfrm_attach( menu, ind, BIND_FUNC, MenuEnglish); dfrm_repack( menu); /* now, install the menu */ dfrm_menu( NULL, menu); } void __CDECL ApTerm( WINDOW *dummy, short msg[]) { UNUSED(dummy); dfrm_free_str( strs); ApplExit(); exit(0); } void main( void) { ApplInit(); strs = dfrm_load_str( "lang.fr"); if( !strs) { FormAlert ( 1, "[1][File \"lang.fr\" not found][END]"); ApplExit(); return; } BuildMenu(); EvntAttach( NULL, AP_TERM, ApTerm); for( ;;) EvntWindom( MU_MESAG); }