From bc078d65d2c8f465eea9a0a37ee3b7db16efa0ae Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 22 Jan 2014 14:32:10 +0100 Subject: [PATCH] fix translations for mac os --- build/macos/linphone.bundle | 9 +++++++++ coreapi/private.h | 2 +- gtk/linphone.h | 4 ++-- gtk/main.c | 28 +++++++++++++++++++++------- oRTP | 2 +- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/build/macos/linphone.bundle b/build/macos/linphone.bundle index 6b44ec400..8008007ce 100644 --- a/build/macos/linphone.bundle +++ b/build/macos/linphone.bundle @@ -92,6 +92,9 @@ ${prefix}/lib/${gtkdir}/${pkg:${gtk}:gtk_binary_version}/engines/*.so + + ${prefix}/lib/${gtkdir}/${pkg:${gtk}:gtk_binary_version}/immodules/*.so + ${prefix}/lib/gio/modules/libgiognutls.so @@ -104,6 +107,12 @@ ${prefix}/share/locale + + ${prefix}/share/locale + + + ${prefix}/share/locale + ${prefix}/share/locale diff --git a/coreapi/private.h b/coreapi/private.h index 37546cd7b..f467c8202 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -66,7 +66,7 @@ extern "C" { #ifdef HAVE_GETTEXT #include #ifndef _ -#define _(String) gettext(String) +#define _(String) dgettext(GETTEXT_PACKAGE,String) #endif #else #ifndef _ diff --git a/gtk/linphone.h b/gtk/linphone.h index f9d918c51..024e6348a 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef ENABLE_NLS # include # undef _ -# define _(String) gettext (String) +# define _(String) dgettext (GETTEXT_PACKAGE,String) #else # define _(String) (String) # define ngettext(singular,plural,number) ((number>1) ? (plural) : (singular) ) @@ -164,4 +164,4 @@ void linphone_gtk_uninit_instance(void); void linphone_gtk_monitor_usb(void); void linphone_gtk_unmonitor_usb(void); -gchar *linphone_gtk_get_record_path(const LinphoneAddress *address, gboolean is_conference); \ No newline at end of file +gchar *linphone_gtk_get_record_path(const LinphoneAddress *address, gboolean is_conference); diff --git a/gtk/main.c b/gtk/main.c index a7de9323b..49ff8542b 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -361,6 +361,8 @@ GtkWidget *linphone_gtk_create_window(const char *window_name){ if (get_ui_file(window_name,path,sizeof(path))==-1) return NULL; + gtk_builder_set_translation_domain(builder,GETTEXT_PACKAGE); + if (!gtk_builder_add_from_file (builder, path, &error)){ g_error("Couldn't load builder file: %s", error->message); g_error_free (error); @@ -387,6 +389,9 @@ GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_n object_ids[1]=NULL; if (get_ui_file(filename,path,sizeof(path))==-1) return NULL; + + gtk_builder_set_translation_domain(builder,GETTEXT_PACKAGE); + if (!gtk_builder_add_objects_from_file(builder,path,object_ids,&error)){ g_error("Couldn't load %s from builder file %s: %s", widget_name,path,error->message); g_error_free (error); @@ -2070,9 +2075,6 @@ static gboolean on_block_termination(void){ #endif int main(int argc, char *argv[]){ -#ifdef ENABLE_NLS - void *p; -#endif char *config_file; const char *factory_config_file; const char *lang; @@ -2122,10 +2124,11 @@ int main(int argc, char *argv[]){ } #ifdef ENABLE_NLS - p=bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); - if (p==NULL) perror("bindtextdomain failed"); + bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); + setlocale(LC_ALL,""); + /*do not use textdomain(): this sets a global default domain. On Mac OS bundle, it breaks gtk translations (obscure bug somewhere)*/ + /*textdomain (GETTEXT_PACKAGE);*/ #else g_message("NLS disabled.\n"); #endif @@ -2159,7 +2162,18 @@ int main(int argc, char *argv[]){ g_error("Could not change directory to %s : %s",workingdir,strerror(errno)); } } - + +#if defined(__APPLE__) && defined(ENABLE_NLS) + /*workaround for bundles. GTK is unable to find translations in the bundle (obscure bug again). + So we help it:*/ + { + if (g_file_test(PACKAGE_LOCALE_DIR, G_FILE_TEST_IS_DIR)){ + bindtextdomain("gtk20",PACKAGE_LOCALE_DIR); + bindtextdomain("gdk-pixbuf",PACKAGE_LOCALE_DIR); + bindtextdomain("glib20",PACKAGE_LOCALE_DIR); + } + } +#endif /* Now, look for the factory configuration file, we do it this late since we want to have had time to change directory and to parse the options, in case we needed to access the working directory */ diff --git a/oRTP b/oRTP index aca5bcf65..b04994f1d 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit aca5bcf65ee64806db02caadb4d4bc1c99a47775 +Subproject commit b04994f1d4f00d802fef64a665f0b77db4d98dee