summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-05-04 22:26:33 +0200
committerGravatar waker <wakeroid@gmail.com>2011-05-04 22:26:33 +0200
commit3ae2505e90a4b9f81930e1cb8c0bae11e3d30932 (patch)
tree536b44b56b93ae49b6c6ff261b7f09907118db91
parent0532ff9092e227f63e3253cd3ca1a52b962c22e1 (diff)
added localization support to portable/static builds
-rw-r--r--main.c24
-rwxr-xr-xscripts/portable_build.sh2
-rwxr-xr-xscripts/portable_postbuild.sh8
3 files changed, 24 insertions, 10 deletions
diff --git a/main.c b/main.c
index 1764e3f3..f398aaa6 100644
--- a/main.c
+++ b/main.c
@@ -591,6 +591,15 @@ restore_resume_state (void) {
int
main (int argc, char *argv[]) {
+#if PORTABLE
+ strcpy (dbinstalldir, argv[0]);
+ char *e = dbinstalldir + strlen (dbinstalldir);
+ while (e >= dbinstalldir && *e != '/') {
+ e--;
+ }
+ *e = 0;
+#endif
+
#ifdef __linux__
signal (SIGSEGV, sigsegv_handler);
#endif
@@ -598,7 +607,13 @@ main (int argc, char *argv[]) {
setlocale (LC_NUMERIC, "C");
#ifdef ENABLE_NLS
// fprintf (stderr, "enabling gettext support: package=" PACKAGE ", dir=" LOCALEDIR "...\n");
+#if PORTABLE
+ char localedir[PATH_MAX];
+ snprintf (localedir, sizeof (localedir), "%s/locale", dbinstalldir);
+ bindtextdomain (PACKAGE, localedir);
+#else
bindtextdomain (PACKAGE, LOCALEDIR);
+#endif
bind_textdomain_codeset (PACKAGE, "UTF-8");
textdomain (PACKAGE);
#endif
@@ -618,15 +633,6 @@ main (int argc, char *argv[]) {
prctl (PR_SET_NAME, "deadbeef-main", 0, 0, 0, 0);
#endif
-#if PORTABLE
- strcpy (dbinstalldir, argv[0]);
- char *e = dbinstalldir + strlen (dbinstalldir);
- while (e >= dbinstalldir && *e != '/') {
- e--;
- }
- *e = 0;
-#endif
-
#if PORTABLE_FULL
if (snprintf (confdir, sizeof (confdir), "%s/config", dbinstalldir) > sizeof (confdir)) {
fprintf (stderr, "fatal: too long install path %s\n", dbinstalldir);
diff --git a/scripts/portable_build.sh b/scripts/portable_build.sh
index c3e396fc..45218e31 100755
--- a/scripts/portable_build.sh
+++ b/scripts/portable_build.sh
@@ -7,7 +7,7 @@ export APBUILD_STATIC_LIBGCC=1
export CC=$ORIGIN/tools/apbuild/apgcc
export CXX=$ORIGIN/tools/apbuild/apgcc
-./configure --enable-staticlink --enable-portable --disable-nls --disable-artwork-imlib2
+./configure --enable-staticlink --enable-portable --disable-artwork-imlib2
sed -i 's/-lstdc++ -lm -lgcc_s -lc -lgcc_s/-lm -lc/g' libtool
make clean
make -j9
diff --git a/scripts/portable_postbuild.sh b/scripts/portable_postbuild.sh
index 0ed1a186..76268386 100755
--- a/scripts/portable_postbuild.sh
+++ b/scripts/portable_postbuild.sh
@@ -64,6 +64,14 @@ done
# icon
cp ./icons/32x32/deadbeef.png $OUTDIR/
+# translations
+mkdir -p $OUTDIR/locale
+for i in po/*.gmo ; do
+ base=`basename po/$i .gmo`
+ mkdir -p $OUTDIR/locale/$base/LC_MESSAGES
+ cp $i $OUTDIR/locale/$base/LC_MESSAGES/deadbeef.mo
+done
+
# strip
if [ $OSTYPE != 'Darwin' ];then
strip --strip-unneeded $OUTDIR/deadbeef