From 8f2491cd0a6a84c91b75232129181519fda18615 Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sat, 18 Oct 2014 19:34:08 +0200 Subject: [PATCH] Support linux packaging structure with shared locale folder. --- openscad.pro | 11 ++++++++++- scripts/release-common.sh | 10 +++++----- src/openscad.cc | 11 ++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/openscad.pro b/openscad.pro index d16da5d3..bbb4f71f 100644 --- a/openscad.pro +++ b/openscad.pro @@ -11,8 +11,15 @@ # qmake Variables to define the installation: # # PREFIX defines the base installation folder +# # LOCALE_PREFIX can overwrite the location of the gettext message catalogs # +# For linux packages that want to install the localization files into +# a folder shared by all packages, specify the LOCALE_PREFIX which will +# force usage of the given folder. +# The default layout is created by: LOCALE_PREFIX=/share/locale +# where is the base installation folder. +# # Please see the 'Building' sections of the OpenSCAD user manual # for updated tips & workarounds. # @@ -479,7 +486,9 @@ target.path = $$PREFIX/bin/ INSTALLS += target LINGUAS = $$cat(po/LINGUAS) -isEmpty(LOCALE_PREFIX):LOCALE_PREFIX = $$PREFIX/share/openscad/po + +!isEmpty(LOCALE_PREFIX): DEFINES += LOCALE_PREFIX=\'\"$$LOCALE_PREFIX\"\' +isEmpty(LOCALE_PREFIX): LOCALE_PREFIX = $$PREFIX/share/openscad/locale for(language, LINGUAS) { catalog = po/$$language/LC_MESSAGES/openscad.mo exists($$catalog) { diff --git a/scripts/release-common.sh b/scripts/release-common.sh index e06646a2..88f4f285 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -326,14 +326,14 @@ case $OS in EXAMPLESDIR=OpenSCAD.app/Contents/Resources/examples LIBRARYDIR=OpenSCAD.app/Contents/Resources/libraries FONTDIR=OpenSCAD.app/Contents/Resources/fonts - TRANSLATIONDIR=OpenSCAD.app/Contents/Resources/po + TRANSLATIONDIR=OpenSCAD.app/Contents/Resources/locale ;; UNIX_CROSS_WIN) cd $OPENSCADDIR EXAMPLESDIR=$DEPLOYDIR/openscad-$VERSION/examples/ LIBRARYDIR=$DEPLOYDIR/openscad-$VERSION/libraries/ FONTDIR=$DEPLOYDIR/openscad-$VERSION/fonts/ - TRANSLATIONDIR=$DEPLOYDIR/openscad-$VERSION/po/ + TRANSLATIONDIR=$DEPLOYDIR/openscad-$VERSION/locale/ rm -rf $DEPLOYDIR/openscad-$VERSION mkdir $DEPLOYDIR/openscad-$VERSION ;; @@ -341,7 +341,7 @@ case $OS in EXAMPLESDIR=openscad-$VERSION/examples/ LIBRARYDIR=openscad-$VERSION/libraries/ FONTDIR=openscad-$VERSION/fonts/ - TRANSLATIONDIR=openscad-$VERSION/po/ + TRANSLATIONDIR=openscad-$VERSION/locale/ rm -rf openscad-$VERSION mkdir openscad-$VERSION ;; @@ -384,8 +384,8 @@ fi if [ -n $TRANSLATIONDIR ]; then echo $TRANSLATIONDIR mkdir -p $TRANSLATIONDIR - tar cvf translations.tar po/*/*/*.mo - cd $TRANSLATIONDIR/.. && tar xvf $OPENSCADDIR/translations.tar && cd $OPENSCADDIR + cd po && tar cvf $OPENSCADDIR/translations.tar */*/*.mo && cd $OPENSCADDIR + cd $TRANSLATIONDIR && tar xvf $OPENSCADDIR/translations.tar && cd $OPENSCADDIR rm -f translations.tar fi diff --git a/src/openscad.cc b/src/openscad.cc index 25a2c392..12d20915 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -161,10 +161,15 @@ static void info() * files. */ void localization_init() { - fs::path po_dir = get_resource_dir("po"); - if (fs::is_directory(po_dir)) { +#ifdef LOCALE_PREFIX + std::string locale_path(LOCALE_PREFIX); +#else + fs::path po_dir = get_resource_dir("locale"); + std::string locale_path(po_dir.string()); +#endif + if (fs::is_directory(locale_path)) { setlocale(LC_ALL,""); - bindtextdomain("openscad", po_dir.string().c_str()); + bindtextdomain("openscad", locale_path.c_str()); bind_textdomain_codeset("openscad", "UTF-8"); textdomain("openscad"); } else {