diff --git a/CMakeLists.txt b/CMakeLists.txt index d0f44d3841435fe5c6f84f30560e3a831305a4e0..74bfc805171f0335b6aae63f1ee7c7a6026f70e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,6 +556,7 @@ FIND_PACKAGE(Gettext) IF(GETTEXT_FOUND) SET(OTB_I18N 1) SET(OTB_LANG "en" CACHE STRING "OTB internationalization (Experimental)")#might want to get the Locale from the system here + SET(OTB_LANG_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/Locale) #TODO compile the po into mo ELSE(GETTEXT_FOUND) SET(OTB_I18N 0) diff --git a/Code/Common/otbI18n.h b/Code/Common/otbI18n.h new file mode 100644 index 0000000000000000000000000000000000000000..dc4fc7897f2d6306db429c5d8af2fe12ac87d5e2 --- /dev/null +++ b/Code/Common/otbI18n.h @@ -0,0 +1,52 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbI18n_h +#define __otbI18n_h + +#include "otbConfigure.h" + +#if defined(OTB_I18N) +#include <libintl.h> +#endif + +//To enable stringization after macro replacement +#define _QUOTEME(x) #x +#define QUOTEME(x) _QUOTEME(x) + + +#if defined(OTB_I18N) +#define otbI18nMacro() \ + setlocale( LC_ALL, QUOTEME(OTB_LANG) );\ + bindtextdomain( "otb", QUOTEME(OTB_LANG_LOCATION) );\ + textdomain( "otb" );\ + std::cout << "Language: " << QUOTEME(OTB_LANG) << std::endl;\ + std::cout << "Language location: " << QUOTEME(OTB_LANG_LOCATION) << std::endl; +#else +#define otbI18nMacro()\ +std::cout << "No internationalization" << std::endl; +#endif + +#if defined(OTB_I18N) +#define otbGetTextMacro(msgString)\ +gettext(msgString) +#else +#define otbGetTextMacro(msgString)\ +msgString +#endif + +#endif \ No newline at end of file diff --git a/OTBConfig.cmake.in b/OTBConfig.cmake.in index 67b59c4ed9169d3c7661a111f605bc91d80c8354..220529478a86782b7724dcb98c8532b8e4d482ef 100644 --- a/OTBConfig.cmake.in +++ b/OTBConfig.cmake.in @@ -135,3 +135,5 @@ SET(OTB_USE_EXTERNAL_BOOST "@OTB_USE_EXTERNAL_BOOST@") # Internationalization SET(OTB_I18N "@OTB_I18N@") +SET(OTB_LANG "@OTB_LANG@") +SET(OTB_LANG_LOCATION "@OTB_LANG_LOCATION@") diff --git a/otbConfigure.h.in b/otbConfigure.h.in index 3bbe3c7cbd74124a2f61c58f9bc06cea7e340eee..dd3846e99d5b1e0b2942f692de48560105ce4e1f 100644 --- a/otbConfigure.h.in +++ b/otbConfigure.h.in @@ -66,4 +66,6 @@ /* Use Visu/Gui configurations */ #cmakedefine OTB_USE_VISU_GUI -#cmakedefine OTB_I18N \ No newline at end of file +#cmakedefine OTB_I18N +#define OTB_LANG @OTB_LANG@ +#define OTB_LANG_LOCATION @OTB_LANG_LOCATION@