|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Language Translation Patch, second attemptHi all
attached is my second attempt at patching the source tree so that also strings outside of wxWidgets can be translated. This one should work on Windows (or at least not break anything) within the SDK. Please test on OSX too. If somebody wants to improve FindGettextLibs.cmake to better support Windows, that's optional but welcome. Please test. Yuv --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx-unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- Index: src/hugin_base/huginapp/ImageCache.cpp =================================================================== --- src/hugin_base/huginapp/ImageCache.cpp (revision 4588) +++ src/hugin_base/huginapp/ImageCache.cpp (working copy) @@ -36,6 +36,9 @@ #include <vigra_ext/Pyramid.h> #include <vigra_ext/FunctorAccessor.h> +// gettext for internalization of strings +#include <libintl.h> +#define _t(String) gettext(String) namespace HuginBase { @@ -506,7 +509,7 @@ return it->second; } else { if (m_progress) { - m_progress->pushTask(AppBase::ProgressTask("Loading image: "+hugin_utils::stripPath(filename), "", 0)); + m_progress->pushTask(AppBase::ProgressTask(_t("Loading image: ")+hugin_utils::stripPath(filename), "", 0)); } #if 1 // load images with VIGRA impex, and store either 8 bit or float images Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt (revision 4588) +++ src/CMakeLists.txt (working copy) @@ -5,10 +5,10 @@ # boost_thread is linked automatically # additionally link to our getopt set(common_libs huginbase hugingetopt - ${PANO_LIBRARIES} ${LAPACK_LIBRARIES} huginlevmar) + ${PANO_LIBRARIES} ${GETTEXT_LIBRARIES} ${LAPACK_LIBRARIES} huginlevmar) ELSE(LAPACK_FOUND) set(common_libs huginbase hugingetopt - ${PANO_LIBRARIES} huginlevmar) + ${PANO_LIBRARIES} ${GETTEXT_LIBRARIES} huginlevmar) ENDIF(LAPACK_FOUND) include_directories( ${CMAKE_SOURCE_DIR}/src/foreign/getopt/include ) ELSE (MSVC) Index: CMakeModules/FindGettextLibs.cmake =================================================================== --- CMakeModules/FindGettextLibs.cmake (revision 0) +++ CMakeModules/FindGettextLibs.cmake (revision 0) @@ -0,0 +1,77 @@ +# Try to find Gettext functionality +# Once done this will define +# +# GETTEXTLIBS_FOUND - system has Gettext +# GETTEXT_INCLUDE_DIR - Gettext include directory +# GETTEXT_LIBRARIES - Libraries needed to use Gettext + +# TODO: This will enable translations only if Gettext functionality is +# present in libc. Must have more robust system for release, where Gettext +# functionality can also reside in standalone Gettext library, or the one +# embedded within kdelibs (cf. gettext.m4 from Gettext source). +# +# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@...> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if (LIBC_HAS_DGETTEXT OR LIBINTL_HAS_DGETTEXT) + + # in cache already + set(GETTEXTLIBS_FOUND TRUE CACHE INTERNAL "") + +else (LIBC_HAS_DGETTEXT OR LIBINTL_HAS_DGETTEXT) + + include(CheckIncludeFiles) + include(CheckLibraryExists) + include(CheckFunctionExists) + + find_path(GETTEXT_INCLUDE_DIR libintl.h + /usr/local/include + /usr/local/include/postgresql + /usr/local/postgresql/include + /usr/local/postgresql/include/postgresql + /usr/include + /usr/include/postgresql + ${PG_TMP} + ) + list(APPEND CMAKE_REQUIRED_INCLUDES ${GETTEXT_INCLUDE_DIR}) + check_include_files(libintl.h HAVE_LIBINTL_H) + set(CMAKE_REQUIRED_INCLUDES) + + set(GETTEXT_LIBRARIES) + + if (HAVE_LIBINTL_H) + check_function_exists(dgettext LIBC_HAS_DGETTEXT) + if (LIBC_HAS_DGETTEXT) + set(GETTEXT_SOURCE "built in libc") + set(GETTEXTLIBS_FOUND TRUE CACHE INTERNAL "") + else (LIBC_HAS_DGETTEXT) + FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl libintl c + PATHS + /usr/lib + /usr/local/lib + ) + CHECK_LIBRARY_EXISTS(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) + if (LIBINTL_HAS_DGETTEXT) + set(GETTEXT_SOURCE "in ${LIBINTL_LIBRARY}") + set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} CACHE FILEPATH "path to libintl library, used for gettext") + set(GETTEXTLIBS_FOUND TRUE CACHE INTERNAL "") + endif (LIBINTL_HAS_DGETTEXT) + endif (LIBC_HAS_DGETTEXT) + endif (HAVE_LIBINTL_H) + + if (GETTEXTLIBS_FOUND) + if (NOT Gettext_FIND_QUIETLY) + message(STATUS "Found Gettext: ${GETTEXT_SOURCE}") + endif (NOT Gettext_FIND_QUIETLY) + else (GETTEXTLIBS_FOUND) + if (Gettext_FIND_REQUIRED) + message(STATUS "Could NOT find Gettext") + endif (Gettext_FIND_REQUIRED) + endif (GETTEXTLIBS_FOUND) + + MARK_AS_ADVANCED(GETTEXT_INCLUDE_DIR GETTEXT_LIBRARIES) + +endif (LIBC_HAS_DGETTEXT OR LIBINTL_HAS_DGETTEXT) Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 4588) +++ CMakeLists.txt (working copy) @@ -219,6 +219,28 @@ ENDIF(MSGFMT_FOUND) ## +## Gettext for the internationalization of CLI tools +## +if (WIN32) + set (GETTEXT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../gettext/include/") + set (GETTEXT_LIBRARIES "${CMAKE_SOURCE_DIR}/../gettext/lib/intl.lib") +else (WIN32) + find_package (GettextLibs) + if (GETTEXTLIBS_FOUND) +# if (NOT "${GETTEXT_LIBRARIES}" STREQUAL "" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib/libc.so" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib64/libc.so") +# set (GAMMU_LIBS "${GAMMU_LIBS} -l${GETTEXT_LIBRARIES}") +# endif (NOT "${GETTEXT_LIBRARIES}" STREQUAL "" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib/libc.so" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib64/libc.so") + else (GETTEXTLIBS_FOUND) + MESSAGE(SEND_ERROR "gettextlibs missing") + endif (GETTEXTLIBS_FOUND) +endif (WIN32) +INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR}) + +## ## LAPACK (optional, enable by -DENABLE_LAPACK=YES ## |
|
|
Re: Language Translation Patch, second attemptOn Wed, Oct 07, 2009 at 05:26:48PM -0400, Yuval Levy wrote: > +// gettext for internalization of strings > +#include <libintl.h> > +#define _t(String) gettext(String) Is this the norm in internationalization of programs. Instead of having all those libs, translation files etc etc. I would like to have the option of simply compiling and using the program in it's native language: #ifdef CONFIG_USE_GETTEXT #include <libintl.h> #define _t(String) gettext(String) #else #define _t(String) String #endif This would allow me to configure MY build without the dependency on the gettext library, and maybe someone else worries about the size of the translation files. Roger. -- ** R.E.Wolff@... ** http://www.BitWizard.nl/ ** +31-15-2600998 ** ** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 ** *-- BitWizard writes Linux device drivers for any device you may have! --* Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement. Does it sit on the couch all day? Is it unemployed? Please be specific! Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx-unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Language Translation Patch, second attemptAm Wednesday 07 October 2009 schrieb Yuval Levy:
> Hi all > > attached is my second attempt at patching the source tree so that also > strings outside of wxWidgets can be translated. > > This one should work on Windows (or at least not break anything) within > the SDK. Please test on OSX too. > > If somebody wants to improve FindGettextLibs.cmake to better support > Windows, that's optional but welcome. > > Please test. > Yuv Kornel -- Kornel Benko Kornel.Benko@... |
|
|
Re: Language Translation Patch, second attemptKornel Benko wrote: > Why not use FindGettext.cmake? because to my understanding FindGettext.cmake finds the tools, not the library, and this is why FindGettextLibs.cmake does - at least on Linux and BSD. For Windows both did not work, so I hard-coded the results in the main CMakeLists.txt. For OSX I don't know, I'm waiting for feedback before committing the fix and make also those strings that are not directly part of the wxWidgets app translatable. Yuv --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx-unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Language Translation Patch, second attemptRogier Wolff wrote: > > On Wed, Oct 07, 2009 at 05:26:48PM -0400, Yuval Levy wrote: >> +// gettext for internalization of strings >> +#include <libintl.h> >> +#define _t(String) gettext(String) > > Is this the norm in internationalization of programs. Instead of > having all those libs, translation files etc etc. I would like to have > the option of simply compiling and using the program in it's native > language: > > #ifdef CONFIG_USE_GETTEXT > #include <libintl.h> > #define _t(String) gettext(String) > #else > #define _t(String) String > #endif > > This would allow me to configure MY build without the dependency > on the gettext library, and maybe someone else worries about > the size of the translation files. I see the benefit of configuring the use or not of gettext / translations - I personally have no use for translations and indeed would prefer a build with less dependency and less disk usage. Configuring it here, however, won't take away the bulk of the translation and the dependency that already exist trhough wxWidgets if I understand correctly. So to do it right, I'd have to find a way to configure wxWidgets not to use gettext and not to do internationalization either. Any help on that? I have submitted this as a patch and not committed it right away because I am not sure that the way I have implemented this is optimal. Maybe there is a better place for this include/define in some common header (it is currently at the level of the individual file to be translated)? I will adapt the patch to be configurable as above, but I don't think this is the last step in making internationalization optional. I am a C++ newbie frying his brain on an itch to understand why C++ is so highly regarded amongst programming languages. If the byproducts of my frying brain are helpful to the project, good. If they are not, that's not critical. And if feedback like yours brings about a better solution, I'm happy to learn from you in the process and update the patch. Yuv --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx-unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Language Translation Patch, second attemptAm Thursday 08 October 2009 schrieb Yuval Levy:
> > Kornel Benko wrote: > > Why not use FindGettext.cmake? > > because to my understanding FindGettext.cmake finds the tools, not the > library, and this is why FindGettextLibs.cmake does - at least on Linux > and BSD. > > For Windows both did not work, so I hard-coded the results in the main > CMakeLists.txt. > > For OSX I don't know, I'm waiting for feedback before committing the fix > and make also those strings that are not directly part of the wxWidgets > app translatable. > > Yuv with libraries. Kornel -- Kornel Benko Kornel.Benko@... |
|
|
Re: Language Translation Patch, second attemptKornel Benko wrote: > Am Thursday 08 October 2009 schrieb Yuval Levy: >> Kornel Benko wrote: >>> Why not use FindGettext.cmake? >> because to my understanding FindGettext.cmake finds the tools, not the >> library, and this is why FindGettextLibs.cmake does - at least on Linux >> and BSD. > > I must have missed something. I did this for the lyx-project. No problems at all > with libraries. maybe it is because the gettext libraries are used by so many packages that you already have them on all machines you tested with? when I first changed the code, I did not even bother with CMake. I simply assumed that gettext was already used/found with wxWindows. THen on Windows, despite gettext in the SDK, I had an error. So I added FindGettext.cmake and looked what it generates. Still did not help Windows. So I googled further and found FindGettextLibs.cmake. I replicated the values that it created in Ubuntu to the Windows equivalent and bingo, it worked. The ultimate test would be to try it on a machine without gettext. Yuv --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx+unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Language Translation Patch, second attemptHi Yuv, > attached is my second attempt at patching the source tree so that also > strings outside of wxWidgets can be translated. > > This one should work on Windows (or at least not break anything) within > the SDK. Please test on OSX too. > it compiles on Windows, but the string does not get translated. (Yes, I added the string to the .po-file). Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx+unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Language Translation Patch, second attemptHi Thomas,
T. Modes wrote: > it compiles on Windows, but the string does not get translated. (Yes, > I added the string to the .po-file). thanks for the feedback. I think now it should be fixed. I found a number of issues: - I forgot to set the bindtextdomain and textdomain in the patch (I am still not sure if I am setting them at the right place). - the folder with the translations was not properly #defined by the CMake Build. - somehow the string already existed in the .po-file, but it had a %s in it that should not be there. rather than working blind, this time I actually installed support for multiple language on my Ubuntu box. It's just disk space... please try again. thank you for your patience. Yuv --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@... To unsubscribe from this group, send email to hugin-ptx+unsubscribe@... For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~--- Index: src/hugin_base/huginapp/ImageCache.cpp =================================================================== --- src/hugin_base/huginapp/ImageCache.cpp (revision 4652) +++ src/hugin_base/huginapp/ImageCache.cpp (working copy) @@ -36,14 +36,18 @@ #include <vigra_ext/Pyramid.h> #include <vigra_ext/FunctorAccessor.h> +// gettext for internalization of strings +#include <hugin_config.h> +#include <libintl.h> +#include <locale.h> +#define _(String) gettext(String) namespace HuginBase { - + using namespace std; using namespace vigra::functor; - template <class T1> class GetRange { @@ -506,7 +510,12 @@ return it->second; } else { if (m_progress) { - m_progress->pushTask(AppBase::ProgressTask("Loading image: "+hugin_utils::stripPath(filename), "", 0)); + + // tell gettext where the translations are and which one to use + bindtextdomain( "hugin", INSTALL_LOCALE_DIR ); + textdomain( "hugin" ); + + m_progress->pushTask(AppBase::ProgressTask(_("Loading image: ")+hugin_utils::stripPath(filename), "", 0)); } #if 1 // load images with VIGRA impex, and store either 8 bit or float images @@ -686,7 +695,11 @@ } else { if (m_progress) { - m_progress->pushTask(AppBase::ProgressTask("Scaling image: "+hugin_utils::stripPath(filename), "", 0)); + // tell gettext where the translations are and which one to use + bindtextdomain( "hugin", INSTALL_LOCALE_DIR ); + textdomain( "hugin" ); + + m_progress->pushTask(AppBase::ProgressTask(_("Scaling image: ")+hugin_utils::stripPath(filename), "", 0)); } DEBUG_DEBUG("creating small image " << name ); EntryPtr entry = getImage(filename); Index: src/hugin_config.h.in.cmake =================================================================== --- src/hugin_config.h.in.cmake (revision 4652) +++ src/hugin_config.h.in.cmake (working copy) @@ -42,7 +42,7 @@ #cmakedefine HAVE_LOG2 0 /* locate of the xrc files, as defined during configuration */ -#define INSTALL_LOCALE_DIR "${INSTALL_LOCALE_DIR}" +#define INSTALL_LOCALE_DIR "${INSTALL_LOCALE_DIR}/" /* Location for data, as defined during configuration*/ #define INSTALL_DATA_DIR "${INSTALL_DATA_DIR}/" Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt (revision 4652) +++ src/CMakeLists.txt (working copy) @@ -5,10 +5,10 @@ # boost_thread is linked automatically # additionally link to our getopt set(common_libs huginbase hugingetopt - ${PANO_LIBRARIES} ${LAPACK_LIBRARIES} huginlevmar) + ${PANO_LIBRARIES} ${GETTEXT_LIBRARIES} ${LAPACK_LIBRARIES} huginlevmar) ELSE(LAPACK_FOUND) set(common_libs huginbase hugingetopt - ${PANO_LIBRARIES} huginlevmar) + ${PANO_LIBRARIES} ${GETTEXT_LIBRARIES} huginlevmar) ENDIF(LAPACK_FOUND) include_directories( ${CMAKE_SOURCE_DIR}/src/foreign/getopt/include ) ELSE (MSVC) Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 4652) +++ CMakeLists.txt (working copy) @@ -219,6 +219,28 @@ ENDIF(MSGFMT_FOUND) ## +## Gettext for the internationalization of CLI tools +## +if (WIN32) + set (GETTEXT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../gettext/include/") + set (GETTEXT_LIBRARIES "${CMAKE_SOURCE_DIR}/../gettext/lib/intl.lib") +else (WIN32) + find_package (GettextLibs) + if (GETTEXTLIBS_FOUND) +# if (NOT "${GETTEXT_LIBRARIES}" STREQUAL "" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib/libc.so" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib64/libc.so") +# set (GAMMU_LIBS "${GAMMU_LIBS} -l${GETTEXT_LIBRARIES}") +# endif (NOT "${GETTEXT_LIBRARIES}" STREQUAL "" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib/libc.so" +# AND NOT "${GETTEXT_LIBRARIES}" STREQUAL "/usr/lib64/libc.so") + else (GETTEXTLIBS_FOUND) + MESSAGE(SEND_ERROR "gettextlibs missing") + endif (GETTEXTLIBS_FOUND) +endif (WIN32) +INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR}) + +## ## LAPACK (optional, enable by -DENABLE_LAPACK=YES ## @@ -283,6 +305,7 @@ ENDIF(NOT MANDIR AND NOT $ENV{MANDIR} STREQUAL "") SET(LOCALEDIR share/locale) +SET(INSTALL_LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/${LOCALEDIR}) SET(ICONDIR share/icons) SET(LINKDIR share/applications) SET(LIBDIR lib${LIB_SUFFIX}) |
| Free embeddable forum powered by Nabble | Forum Help |