• Main Page
  • Classes
  • Files
  • Directories
  • File List
  • File Members

vtkKWInternationalization.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWInternationalization.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 #ifndef __vtkKWInternationalization_h
00015 #define __vtkKWInternationalization_h
00016 
00017 #include "vtkObject.h"
00018 #include "vtkKWWidgets.h"  // Needed for export symbols directives
00019 
00020 /* ----------------------------------------------------------------------
00021    If Internationalization is supported, provide simple macros to 
00022    map gettext function calls.
00023    Some macros rely on the GETTEXT_DOMAIN symbol to be defined as the quoted
00024    name of the text domain that applies to the compilation unit. 
00025    This is done automatically by the KWWidgets_CREATE_GETTEXT_TARGETS
00026    macro (KWWidgetsInternationalizationMacros.cmake) so that the below macros
00027    can be used directly and expand to the right text domain automatically.
00028  */
00029 
00030 #ifdef KWWidgets_USE_INTERNATIONALIZATION
00031 #  include <libintl.h>  // Bring gettext
00032 #  undef _
00033 #  define _(string) gettext(string)
00034 #  undef k_
00035 #  define k_(string) dgettext(GETTEXT_DOMAIN, string)
00036 #else
00037 #  undef _
00038 #  define _(string) string
00039 #  undef k_
00040 #  define k_(string) string
00041 #  undef gettext
00042 #  define gettext(string) string
00043 #  undef dgettext
00044 #  define dgettext(domain,string) string
00045 #endif
00046 
00047 #ifndef GETTEXT_DOMAIN
00048 #define GETTEXT_DOMAIN ""
00049 #endif
00050 
00051 #define gettext_noop(string) string
00052 #define N_(string) gettext_noop(string)
00053 
00054 /* ----------------------------------------------------------------------
00055    Declare some gettext functions that support enlengthen strings. 
00056    Enlengthen strings make use of a special *separator* as a mean
00057    to provide more context and disambiguate short GUI strings.
00058    Example: "Menu|File|Open" instead of "Open"
00059    See gettext "10.2.6 How to use gettext in GUI programs".
00060 */
00061 
00062 //BTX
00063 KWWidgets_EXTERN KWWidgets_EXPORT char* kww_sgettext(const char *msgid);
00064 KWWidgets_EXTERN KWWidgets_EXPORT char* kww_sdgettext(const char *domain_name, const char *msgid);
00065 //ETX
00066 
00067 #define s_(string) kww_sgettext(string)
00068 #define ks_(string) kww_sdgettext(GETTEXT_DOMAIN, string)
00069 
00070 /* ---------------------------------------------------------------------- */
00071 
00072 class KWWidgets_EXPORT vtkKWInternationalization : public vtkObject
00073 {
00074 public:
00075   static vtkKWInternationalization* New();
00076   vtkTypeRevisionMacro(vtkKWInternationalization,vtkObject);
00077   void PrintSelf(ostream& os, vtkIndent indent);
00078 
00079   // Description:
00080   // Set/Get the current global domain of the LC_MESSAGES category. 
00081   // This domain specifies where the internationalized/translated strings
00082   // are coming from.
00083   // The argument is a null-terminated string, whose characters must be legal
00084   // in the use in filenames. 
00085   static void SetCurrentTextDomain(const char *domain_name);
00086   static const char* GetCurrentTextDomain();
00087 
00088   // Description:
00089   // Set/Get the binding between a domain and a message catalog directory.
00090   // The directory should be top-most directory containing the sub-directories
00091   // for each locale/language (ex: fr, zh_CN). Each language subdirectory has 
00092   // a LC_MESSAGES subdirectory where the message catalog for that specific
00093   // domain can be found (ex: dir/fr/LC_MESSAGES/myapp.mo).
00094   static void SetTextDomainBinding(const char *domain_name, const char *dir);
00095   static const char* GetTextDomainBinding(const char *domain_name);
00096 
00097   // Description:
00098   // This method tries *really* hard to find *and* set a message catalog 
00099   // directory for a specific domain. 
00100   // Another signature accepts a semi-colon separated list of directories
00101   // to search message catalogs for.
00102   // Returns catalog directory if it was found, NULL otherwise.
00103   static const char* FindTextDomainBinding(const char *domain_name);
00104   static const char* FindTextDomainBinding(
00105     const char *domain_name, const char *dirs_to_search);
00106 
00107 protected:
00108   vtkKWInternationalization() {};
00109   ~vtkKWInternationalization() {};
00110 
00111 private:
00112   vtkKWInternationalization(const vtkKWInternationalization&); // Not implemented
00113   void operator=(const vtkKWInternationalization&); // Not implemented
00114 };
00115 
00116 #endif

Generated on Mon Aug 16 2010 18:58:44 for KWWidgets by  doxygen 1.7.1