home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / tools / system / shutdown / localesupport.c < prev    next >
C/C++ Source or Header  |  1993-03-01  |  1KB  |  90 lines

  1. /*
  2. **    Shutdown 2.0 package, LocaleSupport.c module
  3. **
  4. **    Copyright © 1992 by Olaf `Olsen' Barthel
  5. **        All Rights Reserved
  6. */
  7.  
  8. #define STRINGARRAY
  9.  
  10. #include "shutdown.h"
  11.  
  12. struct LocaleBase    *LocaleBase;
  13. STATIC struct Catalog    *Catalog;
  14.  
  15.     /* LocaleOpen(STRPTR CatalogName,STRPTR BuiltIn):
  16.      *
  17.      *    Open string translation tables.
  18.      */
  19.  
  20. VOID __regargs
  21. LocaleOpen(STRPTR CatalogName,STRPTR BuiltIn)
  22. {
  23.     if(LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library",0))
  24.     {
  25.         if(!(Catalog = OpenCatalog(NULL,CatalogName,
  26.             OC_BuiltInLanguage,    BuiltIn,
  27.         TAG_DONE)))
  28.         {
  29.             CloseLibrary(LocaleBase);
  30.  
  31.             LocaleBase = NULL;
  32.         }
  33.     }
  34. }
  35.  
  36.     /* LocaleClose():
  37.      *
  38.      *    Close the translation tables.
  39.      */
  40.  
  41. VOID
  42. LocaleClose(VOID)
  43. {
  44.     if(Catalog)
  45.         CloseCatalog(Catalog);
  46.  
  47.     if(LocaleBase)
  48.         CloseLibrary(LocaleBase);
  49. }
  50.  
  51.     /* GetString(LONG ID):
  52.      *
  53.      *    Obtain a string from the translation pool.
  54.      */
  55.  
  56. STRPTR __regargs
  57. GetString(LONG ID)
  58. {
  59.     STRPTR Builtin = NULL;
  60.  
  61.     if(AppStrings[ID] . as_ID == ID)
  62.         Builtin = AppStrings[ID] . as_Str;
  63.     else
  64.     {
  65.         WORD i;
  66.  
  67.         for(i = 0 ; i < (sizeof(AppStrings) / sizeof(struct AppString)) ; i++)
  68.         {
  69.             if(AppStrings[i] . as_ID == ID)
  70.             {
  71.                 Builtin = AppStrings[i] . as_Str;
  72.  
  73.                 break;
  74.             }
  75.         }
  76.     }
  77.  
  78.     if(LocaleBase)
  79.     {
  80.         STRPTR String = GetCatalogStr(Catalog,ID,Builtin);
  81.  
  82.         if(String[0])
  83.             return(String);
  84.         else
  85.             return(Builtin);
  86.     }
  87.     else
  88.         return(Builtin);
  89. }
  90.