From: <hug...@li...> - 2011-01-08 23:26:37
|
branch: details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/8c1cf052730f changeset: 4806:8c1cf052730f user: Yuval Levy <yu...@us...> date: Sat Jan 08 18:01:14 2011 -0500 description: * use relative path for translations outside wX (must still be verified for Windows and OSX if the path set is correct) * segregated binding of translation into hugin_utils::TranslateText() diffstat: src/hugin_base/hugin_utils/utils.cpp | 40 +++++++++++++++++++++++++++++++++- src/hugin_base/hugin_utils/utils.h | 5 ++- src/hugin_base/huginapp/ImageCache.cpp | 6 +---- 3 files changed, 43 insertions(+), 8 deletions(-) diffs (93 lines): diff -r 4e1d02bda2b9 -r 8c1cf052730f src/hugin_base/hugin_utils/utils.cpp --- a/src/hugin_base/hugin_utils/utils.cpp Sun Jan 02 16:02:30 2011 -0500 +++ b/src/hugin_base/hugin_utils/utils.cpp Sat Jan 08 18:01:14 2011 -0500 @@ -263,5 +263,43 @@ b = 0.0; } - + void TranslateText(){ + // locate the translations + #if _WINDOWS + char buffer[MAX_PATH];//always use MAX_PATH for filepaths + GetModuleFileName(NULL,buffer,sizeof(buffer)); + std::string working_path=(buffer); + std::string locale_path=""; + //remove filename + std::string::size_type pos=working_path.rfind("\\"); + if(pos!=std::string::npos) + { + working_path.erase(pos); + //remove last dir: should be bin + pos=working_path.rfind("\\"); + if(pos!=std::string::npos) + { + working_path.erase(pos); + //append path delimiter and path + working_path.append("\\share\\hugin\\data\\"); + locale_path=working_path; + } + } + #elif defined MAC_SELF_CONTAINED_BUNDLE + char path[PATH_MAX + 1]; + uint32_t size = sizeof(path); + std::string locale_path(""); + if (_NSGetExecutablePath(path, &size) == 0) + { + locale_path=dirname(path); + locale_path.append("/../Resources/xrc/"); + } + #else + std::string locale_path = (INSTALL_DATA_DIR); + #endif + // and tell gettext where the translations are and which one to use + bindtextdomain( "hugin", locale_path.c_str() ); + textdomain( "hugin" ); + } + } //namespace diff -r 4e1d02bda2b9 -r 8c1cf052730f src/hugin_base/hugin_utils/utils.h --- a/src/hugin_base/hugin_utils/utils.h Sun Jan 02 16:02:30 2011 -0500 +++ b/src/hugin_base/hugin_utils/utils.h Sat Jan 08 18:01:14 2011 -0500 @@ -42,7 +42,6 @@ #define _X(String) gettext(String) - #if 0 // ?????????????????????????????????????????? #ifdef __WXMSW__ @@ -153,7 +152,7 @@ namespace hugin_utils { - + /** current time as a string */ IMPEX std::string CurrentTime(); @@ -294,6 +293,8 @@ IMPEX void ControlPointErrorColour(const double cperr, double &r,double &g, double &b); + void TranslateText(); + } // namespace diff -r 4e1d02bda2b9 -r 8c1cf052730f src/hugin_base/huginapp/ImageCache.cpp --- a/src/hugin_base/huginapp/ImageCache.cpp Sun Jan 02 16:02:30 2011 -0500 +++ b/src/hugin_base/huginapp/ImageCache.cpp Sat Jan 08 18:01:14 2011 -0500 @@ -507,11 +507,7 @@ return it->second; } else { if (m_progress) { - - // tell gettext where the translations are and which one to use - bindtextdomain( "hugin", INSTALL_LOCALE_DIR ); - textdomain( "hugin" ); - + hugin_utils::TranslateText(); m_progress->pushTask(AppBase::ProgressTask(_X("Loading image:")+std::string(" ")+hugin_utils::stripPath(filename), "", 0)); } |