]> www.fi.muni.cz Git - evince.git/blobdiff - previewer/ev-previewer.c
[windows] Fix localization on Windows
[evince.git] / previewer / ev-previewer.c
index 7a83eee07be11e347938b7ed6cc63aa11496dc71..14d4f2f332306543779310a2f53998b61013c0b5 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include <config.h>
@@ -33,7 +33,9 @@
 #endif
 #include <io.h>
 #include <conio.h>
-#define _WIN32_WINNT 0x0500
+#if !(_WIN32_WINNT >= 0x0500)
+#error "_WIN32_WINNT must be defined >= 0x0500"
+#endif
 #include <windows.h>
 #endif
 
@@ -84,8 +86,12 @@ ev_previewer_load_document (const gchar     *filename,
 {
        EvJob *job;
        gchar *uri;
+       GFile  *file;
+
+       file = g_file_new_for_commandline_arg (filename);
+       uri = g_file_get_uri (file);
+       g_object_unref (file);
 
-       uri = g_filename_to_uri (filename, NULL, NULL);
        job = ev_job_load_new (uri);
        g_signal_connect (job, "finished",
                          G_CALLBACK (ev_previewer_load_job_finished),
@@ -94,6 +100,33 @@ ev_previewer_load_document (const gchar     *filename,
        g_free (uri);
 }
 
+static gchar*
+ev_previewer_get_locale_dir ()
+{
+#ifdef G_OS_WIN32
+       gchar *install_dir = NULL, *locale_dir;
+       gchar *retval = NULL;
+
+       install_dir =
+           g_win32_get_package_installation_directory_of_module (NULL);
+
+       if (install_dir) {
+               locale_dir = g_build_filename (install_dir,
+                                       "share", "locale", NULL);
+               retval = g_win32_locale_filename_from_utf8 (locale_dir);
+               g_free (install_dir);
+               g_free (locale_dir);
+       }
+
+       if (retval)
+               return retval;
+       else
+               return g_strdup ("");
+#else
+       return g_strdup (GNOMELOCALEDIR);
+#endif
+}
+
 gint
 main (gint argc, gchar **argv)
 {
@@ -133,7 +166,9 @@ main (gint argc, gchar **argv)
 
 #ifdef ENABLE_NLS
        /* Initialize the i18n stuff */
-       bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+       gchar *tmp = ev_previewer_get_locale_dir ();
+       bindtextdomain (GETTEXT_PACKAGE, tmp);
+       g_free (tmp);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
 #endif