From f5de37dbcfa549913c360c26491b8264457fa59a Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Thu, 11 Oct 2012 12:06:56 +0200 Subject: Basic gettext support when building Added basic support for building gettext locales in the Makefile. The po file name should match the target locale. [Dirk Hohndel: Used git mv to rename the German .po file] Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a954f54a6..6ecef7904 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ gtk-gui.o statistics.o file.o cochran.o $(OSSUPPORT).o $(RESFILE) -$(NAME): $(OBJS) +$(NAME): $(OBJS) gettext $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS) install: $(NAME) @@ -211,8 +211,16 @@ uemis-downloader.o: uemis-downloader.c dive.h uemis.h $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c +gettext: po/*.po + @for MSG in $(wildcard po/*.po); do \ + LOC=`basename $$MSG .po`; \ + mkdir -p locale/$$LOC.UTF-8/LC_MESSAGES; \ + msgfmt -c -o locale/$$LOC.UTF-8/LC_MESSAGES/subsurface.mo $$MSG; \ + done + doc: $(MAKE) -C Documentation doc clean: rm -f $(OBJS) *~ $(NAME) $(NAME).exe + rm -rf locale -- cgit v1.2.3-70-g09d2 From cfaa5563bf298ea75cdd69f23ab32bc7d222f875 Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Fri, 12 Oct 2012 10:05:41 +0200 Subject: Better gettext build My previous take at adding gettext to the Makefile wasn't very good, since it always relinked the subsurface executable. Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6ecef7904..e747c5a3b 100644 --- a/Makefile +++ b/Makefile @@ -118,11 +118,14 @@ endif LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm +MSGLANGS=$(notdir $(wildcard po/*po)) +MSGOBJS=$(addprefix locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) + OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ gtk-gui.o statistics.o file.o cochran.o $(OSSUPPORT).o $(RESFILE) -$(NAME): $(OBJS) gettext +$(NAME): $(OBJS) $(MSGOBJS) $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS) install: $(NAME) @@ -211,12 +214,9 @@ uemis-downloader.o: uemis-downloader.c dive.h uemis.h $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c -gettext: po/*.po - @for MSG in $(wildcard po/*.po); do \ - LOC=`basename $$MSG .po`; \ - mkdir -p locale/$$LOC.UTF-8/LC_MESSAGES; \ - msgfmt -c -o locale/$$LOC.UTF-8/LC_MESSAGES/subsurface.mo $$MSG; \ - done +locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po + mkdir -p $(dir $@) + msgfmt -c -o $@ po/$*.po doc: $(MAKE) -C Documentation doc -- cgit v1.2.3-70-g09d2 From ef039c9d32e998af3ceab21673a51169f6e4f1ed Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Mon, 15 Oct 2012 14:44:01 +0200 Subject: Support for gettext in MacOSX application bundle The MacOSX applications bundle needs to be told where to bind the text domain from. Also copy the gettext .mo files in the install-macosx target. [Dirk Hohndel: minor change in main(): move the path declaration to the beginning of the function] Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- Makefile | 4 ++++ dive.h | 1 + linux.c | 5 +++++ macos.c | 13 +++++++++++++ main.c | 4 +++- windows.c | 5 +++++ 6 files changed, 31 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e747c5a3b..af2284f96 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,10 @@ install-macosx: $(NAME) $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/ $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ + $(INSTALL) -d -m 755 $(addprefix $(MACOSXINSTALL)/Contents/Resources/,$(dir $(MSGOBJS))) + for MSG in $(MSGOBJS); do\ + install $$MSG $(MACOSXINSTALL)/Contents/Resources/$$MSG;\ + done file.o: file.c dive.h file.h $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) $(ZIP) -c file.c diff --git a/dive.h b/dive.h index 42c09b581..fb1a1baa6 100644 --- a/dive.h +++ b/dive.h @@ -435,6 +435,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 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 f60f9179c..b97e54f27 100644 --- a/linux.c +++ b/linux.c @@ -84,6 +84,11 @@ const char *subsurface_default_filename() } } +const char *subsurface_gettext_domainpath() +{ + return "./locale"; +} + void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager) { diff --git a/macos.c b/macos.c index 3cc4ddf1e..3d9c9b5cd 100644 --- a/macos.c +++ b/macos.c @@ -104,6 +104,19 @@ const char *subsurface_default_filename() } } +const char *subsurface_gettext_domainpath() +{ + CFBundleRef mainBundle = CFBundleGetMainBundle(); + CFURLRef localeURL = CFBundleCopyResourceURL(mainBundle, CFSTR("locale"), CFSTR(""), NULL); + if (localeURL) { + CFStringRef localePath = CFURLCopyFileSystemPath(localeURL, kCFURLPOSIXPathStyle); + CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); + const char *path = CFStringGetCStringPtr(localePath, encodingMethod); + return path; + } + return "./locale"; +} + static void show_main_window(GtkWidget *w, gpointer data) { gtk_widget_show(main_window); diff --git a/main.c b/main.c index 1ca484d0c..cdf95638a 100644 --- a/main.c +++ b/main.c @@ -225,12 +225,14 @@ int main(int argc, char **argv) { int i; gboolean no_filenames = TRUE; + const char *path; /* 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 */ setlocale( LC_ALL, "" ); - bindtextdomain("subsurface", "./locale"); + path = subsurface_gettext_domainpath(); + bindtextdomain("subsurface", path); bind_textdomain_codeset("subsurface", "utf-8"); textdomain("subsurface"); output_units = SI_units; diff --git a/windows.c b/windows.c index eedeccf15..b099193f8 100644 --- a/windows.c +++ b/windows.c @@ -151,6 +151,11 @@ const char *subsurface_default_filename() } } +const char *subsurface_gettext_domainpath() +{ + return "./locale"; +} + void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager) { -- cgit v1.2.3-70-g09d2