]> source.dussan.org Git - tigervnc.git/commitdiff
Include translations in macOS and Windows builds 1318/head
authorPierre Ossman <ossman@cendio.se>
Fri, 27 Aug 2021 09:15:54 +0000 (11:15 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 27 Aug 2021 12:49:10 +0000 (14:49 +0200)
release/makemacapp.in
release/tigervnc.iss.in
vncviewer/vncviewer.cxx

index 2bfd869e40df50dfe10bd959098d88f4ee87bd81..0c3f9626cf926578d3df5bb19d85567025d55253 100644 (file)
@@ -67,6 +67,12 @@ fi
 install -m 644 $SRCDIR/release/tigervnc.icns "$APPROOT/Contents/Resources/"
 install -m 644 release/Info.plist "$APPROOT/Contents/"
 
+for lang in `cat "$SRCDIR/po/LINGUAS"`; do
+       mkdir -p "$APPROOT/Contents/Resources/locale/$lang/LC_MESSAGES"
+       install -m 644 po/$lang.mo \
+               "$APPROOT/Contents/Resources/locale/$lang/LC_MESSAGES/tigervnc.mo"
+done
+
 install -m 644 $SRCDIR/LICENCE.TXT $TMPDIR/dmg/
 install -m 644 $SRCDIR/README.rst $TMPDIR/dmg/
 
index a7b9b7018085f31598332a033b2c543b5e5c6b04..bad0290b67b621779c0760ee0d54b104ba987e8d 100644 (file)
@@ -23,6 +23,14 @@ Source: "@CMAKE_BINARY_DIR@\vncviewer\vncviewer.exe"; DestDir: "{app}"; Flags: i
 Source: "@CMAKE_SOURCE_DIR@\README.rst"; DestDir: "{app}"; Flags: ignoreversion
 Source: "@CMAKE_SOURCE_DIR@\LICENCE.TXT"; DestDir: "{app}"; Flags: ignoreversion
 
+#define LINGUAS
+#define Lang
+#sub AddLanguage
+  #define Lang = FileRead(LINGUAS)
+  Source: "@CMAKE_BINARY_DIR@\po\{#Lang}.mo"; DestDir: "{app}\locale\{#Lang}\LC_MESSAGES"; DestName: "tigervnc.mo"; Flags: ignoreversion
+#endsub
+#for {LINGUAS = FileOpen("@CMAKE_SOURCE_DIR@\po\LINGUAS"); !FileEof(LINGUAS); ""} AddLanguage
+
 [Icons]
 Name: "{group}\TigerVNC Viewer"; FileName: "{app}\vncviewer.exe";
 Name: "{group}\Listening TigerVNC Viewer"; FileName: "{app}\vncviewer.exe"; Parameters: "-listen";
index 1092f1f46ad079e039b4591525d5e13a7b132391..2a81ffd3dd2ee0d7a486c852073d9e00da3572e3 100644 (file)
 #define mkdir(path, mode) _mkdir(path)
 #endif
 
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+#endif
+
 #if !defined(WIN32) && !defined(__APPLE__)
 #include <X11/Xlib.h>
 #include <X11/XKBlib.h>
@@ -261,6 +265,57 @@ static void CleanupSignalHandler(int sig)
   exit(1);
 }
 
+static const char* getlocaledir()
+{
+#if defined(WIN32)
+  static char localebuf[PATH_MAX];
+  char *slash;
+
+  GetModuleFileName(NULL, localebuf, sizeof(localebuf));
+
+  slash = strrchr(localebuf, '\\');
+  if (slash == NULL)
+    return NULL;
+
+  *slash = '\0';
+
+  if ((strlen(localebuf) + strlen("\\locale")) >= sizeof(localebuf))
+    return NULL;
+
+  strcat(localebuf, "\\locale");
+
+  return localebuf;
+#elif defined(__APPLE__)
+  CFBundleRef bundle;
+  CFURLRef localeurl;
+  CFStringRef localestr;
+  Boolean ret;
+
+  static char localebuf[PATH_MAX];
+
+  bundle = CFBundleGetMainBundle();
+  if (bundle == NULL)
+    return NULL;
+
+  localeurl = CFBundleCopyResourceURL(bundle, CFSTR("locale"),
+                                      NULL, NULL);
+  if (localeurl == NULL)
+    return NULL;
+
+  localestr = CFURLCopyFileSystemPath(localeurl, kCFURLPOSIXPathStyle);
+
+  CFRelease(localeurl);
+
+  ret = CFStringGetCString(localestr, localebuf, sizeof(localebuf),
+                           kCFStringEncodingUTF8);
+  if (!ret)
+    return NULL;
+
+  return localebuf;
+#else
+  return CMAKE_INSTALL_FULL_LOCALEDIR;
+#endif
+}
 static void init_fltk()
 {
   // Basic text size (10pt @ 96 dpi => 13px)
@@ -588,12 +643,18 @@ static int mktunnel()
 
 int main(int argc, char** argv)
 {
+  const char *localedir;
   UserDialog dlg;
 
   argv0 = argv[0];
 
   setlocale(LC_ALL, "");
-  bindtextdomain(PACKAGE_NAME, CMAKE_INSTALL_FULL_LOCALEDIR);
+
+  localedir = getlocaledir();
+  if (localedir == NULL)
+    fprintf(stderr, "Failed to determine locale directory\n");
+  else
+    bindtextdomain(PACKAGE_NAME, localedir);
   textdomain(PACKAGE_NAME);
 
   // Write about text to console, still using normal locale codeset