summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--linux.c10
-rw-r--r--macos.c4
-rw-r--r--main.c2
-rw-r--r--windows.c5
5 files changed, 17 insertions, 6 deletions
diff --git a/dive.h b/dive.h
index 1394ebc80..d88ee1d92 100644
--- a/dive.h
+++ b/dive.h
@@ -440,7 +440,7 @@ extern const char *star_strings[];
extern const char *default_filename;
extern const char *existing_filename;
extern const char *subsurface_default_filename(void);
-extern const char *subsurface_gettext_domainpath(void);
+extern const char *subsurface_gettext_domainpath(char *);
extern void subsurface_command_line_init(gint *, gchar ***);
extern void subsurface_command_line_exit(gint *, gchar ***);
#define AIR_PERMILLE 209
diff --git a/linux.c b/linux.c
index 5861411ee..c11bc2f0c 100644
--- a/linux.c
+++ b/linux.c
@@ -84,9 +84,15 @@ const char *subsurface_default_filename()
}
}
-const char *subsurface_gettext_domainpath()
+const char *subsurface_gettext_domainpath(char *argv0)
{
- return "./share/locale";
+ if (argv0[0] == '.') {
+ /* we're starting a local copy */
+ return "./share/locale";
+ } else {
+ /* subsurface is installed, so system dir should be fine */
+ return NULL;
+ }
}
void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
diff --git a/macos.c b/macos.c
index 585e879b0..fb760887f 100644
--- a/macos.c
+++ b/macos.c
@@ -104,8 +104,10 @@ const char *subsurface_default_filename()
}
}
-const char *subsurface_gettext_domainpath()
+const char *subsurface_gettext_domainpath(char *argv0)
{
+ /* on a Mac we ignore the argv0 argument and instead use the resource_path
+ * to figure out where to find the translation files */
static char buffer[256];
const char *resource_path = quartz_application_get_resource_path();
if (resource_path) {
diff --git a/main.c b/main.c
index 379b35280..880f5f5cc 100644
--- a/main.c
+++ b/main.c
@@ -230,7 +230,7 @@ int main(int argc, char **argv)
/* set up l18n - the search directory needs to change
* so that it uses the correct system directory when
* subsurface isn't run from the local directory */
- path = subsurface_gettext_domainpath();
+ path = subsurface_gettext_domainpath(argv[0]);
setlocale( LC_ALL, "" );
bindtextdomain("subsurface", path);
bind_textdomain_codeset("subsurface", "utf-8");
diff --git a/windows.c b/windows.c
index 4aa05a22b..1c8cd0a01 100644
--- a/windows.c
+++ b/windows.c
@@ -151,11 +151,14 @@ const char *subsurface_default_filename()
}
}
-const char *subsurface_gettext_domainpath()
+const char *subsurface_gettext_domainpath(char *argv0)
{
+ /* first hackishly make sure that the LANGUAGE information is correctly set up
+ * in the environment */
char buffer[80];
snprintf(buffer, sizeof(buffer), "LANGUAGE=%s.UTF-8", g_win32_getlocale());
putenv(buffer);
+ /* always use translation directory relative to install location, regardless of argv0 */
return "./share/locale";
}