Initial commit.
[amiga/xmodule.git] / Locale_c.sd
1 ##stringtype C
2 ##shortstrings
3 /*
4 **      Locale.c
5 **
6 **      Copyright (C) 1994,95,96,97 Bernardo Innocenti
7 **
8 **      Routines to handle localization.
9 **
10 **      NOTE: The Locale.c file is generated automatically by `%fv'
11 **            using "%f0". Do NOT edit by hand!
12 */
13
14 #include <libraries/locale.h>
15
16 #include <proto/exec.h>
17 #include <proto/locale.h>
18
19 #include "XModulePriv.h"
20
21
22 #define CATALOGVERSION  %v
23 #define CATALOGNAME             "%b.catalog"
24 #define MSG_COUNT               %n
25
26
27 STRPTR AppStrings[] =
28 {
29         %s%(,)
30 };
31
32 static struct Library           *LocaleBase = NULL;
33 XDEF struct Catalog                     *Catalog = NULL;
34
35
36
37 GLOBALCALL void SetupLocale (void)
38 {
39         /* Try to open locale.library */
40         if (LocaleBase = OpenLibrary ("locale.library", 38L))
41         {
42                 /* Try to get catalog for current language */
43                 if (Catalog = OpenCatalog (NULL, CATALOGNAME,
44                         OC_BuiltInLanguage,     "english",
45                         OC_Version,                     CATALOGVERSION,
46                         TAG_DONE))
47                 {
48                         /* Read in locale language strings */
49                         UBYTE **as = AppStrings;
50                         ULONG i;
51
52                         /* Get translation strings */
53                         for (i = 1; i < MSG_COUNT; i++, as++)
54                                 *as = GetCatalogStr (Catalog, i, *as);
55                 }
56         }
57
58         /* Fix for a limitation of FlexCat: MSG_NULL should translate
59          * to a NULL pointer, not a pointer to an empty string :)
60          */
61         AppStrings[0] = NULL;
62 }
63
64
65
66 GLOBALCALL void CleanupLocale (void)
67 {
68         if (LocaleBase)
69         {
70                 /* No need to check for NULL */
71                 CloseCatalog (Catalog);         Catalog = NULL;
72                 CloseLibrary (LocaleBase);      LocaleBase = NULL;
73         }
74 }