#include <intuition/intuition.h>
#include <libraries/gadtools.h>
#include <libraries/locale.h>

#include <proto/exec.h>
#include <proto/locale.h>

#define CATCOMP_NUMBERS
#define CATCOMP_BLOCK
#define CATCOMP_CODE
#include "PSM_strings.h"

/* in PSM.c */
extern STRPTR shanghailabels[], poppublabels[];
extern struct EasyStruct easyr;
extern struct NewMenu psmnewmenus[], pubscrnewmenus[];
extern struct NewBroker newbroker;



extern STRPTR __asm GetString(register __a0 struct LocaleInfo *li,
                       register __d0 LONG stringNum);

static struct LocaleInfo li;
static struct Library *LocaleBase;

char *s_opennew, *s_closescr, *s_moveto, *s_refresh, *s_makedef, *s_keepop,
     *s_closeaft, *s_shanoff, *s_shanon, *s_popoff, *s_popon, *s_hide,
     *s_quit, *s_about, *s_cool, *s_cantquit, *s_quitcanc, *s_noasl,
     *s_cantclose, *s_continue;

void initLocale( void )
{
li.li_Catalog = NULL;
if ( LocaleBase = OpenLibrary( "locale.library", 38L ) )
	{
	li.li_LocaleBase = LocaleBase;
	li.li_Catalog = OpenCatalogA( NULL, "PSM.catalog", NULL );
	}

shanghailabels[0] = GetString( &li, MSG_SHANGHAIOFF_MGAD );
shanghailabels[1] = GetString( &li, MSG_SHANGHAION_MGAD );
poppublabels[0] = GetString( &li, MSG_POPPUBOFF_MGAD );
poppublabels[1] = GetString( &li, MSG_POPPUBON_MGAD );
easyr.es_Title = GetString( &li, MSG_NOTIFY );
psmnewmenus[0].nm_Label = pubscrnewmenus[0].nm_Label = GetString( &li, MSG_PROJECT_MENU );
psmnewmenus[1].nm_Label = GetString( &li, MSG_ABOUT_MENU );
psmnewmenus[1].nm_CommKey = GetString( &li, MSG_ABOUT_HK );
psmnewmenus[2].nm_Label = GetString( &li, MSG_HIDE_MENU );
psmnewmenus[2].nm_CommKey = GetString( &li, MSG_HIDE_HK );
psmnewmenus[3].nm_Label = GetString( &li, MSG_QUIT_MENU );
psmnewmenus[3].nm_CommKey = GetString( &li, MSG_QUIT_HK );
psmnewmenus[4].nm_Label = GetString( &li, MSG_PREFS_MENU );
psmnewmenus[5].nm_Label = GetString( &li, MSG_FONT_MENU );
psmnewmenus[5].nm_CommKey = GetString( &li, MSG_FONT_HK );
psmnewmenus[6].nm_Label = GetString( &li, MSG_PATT_MENU );
psmnewmenus[6].nm_CommKey = GetString( &li, MSG_PATT_HK );
pubscrnewmenus[2].nm_Label = GetString( &li, MSG_CLOSESCREEN_GAD );
newbroker.nb_Descr = GetString( &li, MSG_BROKER );

s_opennew = GetString( &li, MSG_OPENNEW_GAD );
s_closescr = GetString( &li, MSG_CLOSESCREEN_GAD );
s_moveto = GetString( &li, MSG_MOVETOSCREEN_GAD );
s_refresh = GetString( &li, MSG_REFRESHLIST_GAD );
s_makedef = pubscrnewmenus[1].nm_Label = GetString( &li, MSG_MAKEDEFAULT_GAD );
s_keepop = GetString( &li, MSG_KEEPOPEN_MGAD );
s_closeaft = GetString( &li, MSG_CLOSEAFT_MGAD );
s_shanoff = GetString( &li, MSG_SHANGHAIOFF_MGAD );
s_shanon = GetString( &li, MSG_SHANGHAION_MGAD );
s_popoff = GetString( &li, MSG_POPPUBOFF_MGAD );
s_popon = GetString( &li, MSG_POPPUBON_MGAD );
s_hide = GetString( &li, MSG_HIDE_GAD );
s_quit = GetString( &li, MSG_QUIT_GAD );
s_about = GetString( &li, MSG_ABOUT );
s_cool = GetString( &li, MSG_COOL );
s_cantquit = GetString( &li, MSG_CANTQUIT );
s_quitcanc = GetString( &li, MSG_QUITCANC );
s_noasl = GetString( &li, MSG_NOASL );
s_cantclose = GetString( &li, MSG_CANTCLOSE );
s_continue = GetString( &li, MSG_CONTINUE );
}


void flushLocale( void )
{
if ( LocaleBase )
	{
	if ( li.li_Catalog )
		CloseCatalog( li.li_Catalog );
	CloseLibrary( LocaleBase );
	}
}
