/************************************************************
* MultiUser - MultiUser Task/File Support System				*
* ---------------------------------------------------------	*
* localized strings for	support commands							*
* ---------------------------------------------------------	*
* © Copyright 1993-1994 Geert Uytterhoeven						*
* All Rights Reserved.													*
************************************************************/

#include "Locale.h"

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

#define MULTIUSERSUPPORTCATALOGNAME    "multiuser_support.catalog"
#define MULTIUSERSUPPORTCATALOGVERSION 1 /* :-) */

#ifndef SIMPLE_LOCALE

#define LocaleBase li->li_LocaleBase

void _OpenLoc(struct ExecBase *SysBase,struct LocaleInfo *li)
{
	li->li_LocaleBase = OpenLibrary("locale.library",38);
	if	(LocaleBase)
		li->li_Catalog = OpenCatalog(0,MULTIUSERSUPPORTCATALOGNAME,
		                             OC_BuiltInLanguage,"english",
		                             OC_Version,MULTIUSERSUPPORTCATALOGVERSION,
		                             TAG_DONE);
	else
		li->li_Catalog = 0;
}

void _CloseLoc(struct ExecBase *SysBase,struct LocaleInfo *li)
{
	if	(li->li_LocaleBase) {
		CloseCatalog(li->li_Catalog);
		CloseLibrary(li->li_LocaleBase);
	}
}

STRPTR _GetLocS(struct ExecBase *SysBase,struct LocaleInfo *li,LONG id,STRPTR defstr)
{
	if	(LocaleBase)
		return(GetCatalogStr(li->li_Catalog,id,defstr));
	else
		return(defstr);
}

#undef LocaleBase

#else

STRPTR _GetLocStr(struct ExecBase *SysBase,LONG id,STRPTR defstr)
{
	struct Library *LocaleBase;
	struct Catalog *cat;
	STRPTR s;

	LocaleBase = OpenLibrary("locale.library",38);
	if	(LocaleBase) {
		cat = OpenCatalog(0,MULTIUSERSUPPORTCATALOGNAME,
		                    OC_BuiltInLanguage,"english",
		                    OC_Version,MULTIUSERSUPPORTCATALOGVERSION,
		                    TAG_DONE);
		s = GetCatalogStr(cat,id,defstr);
		CloseCatalog(cat);
		CloseLibrary(LocaleBase);
	}
	else s = defstr;

	return(s);
}

#endif
