From de74250a3e0917cad8dbd163b854b3e6b4bfbee9 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Fri, 25 Feb 2011 21:50:21 +0000 Subject: Building translated nib files if strings file exist. svn path=/trunk/netsurf/; revision=11802 --- cocoa/Makefile.target | 18 +++++++++++++----- cocoa/NetSurf.xcodeproj/project.pbxproj | 12 ++++++++++++ cocoa/compile-xib.sh | 20 ++++++++++++++++++++ cocoa/extract-strings.sh | 11 +++++++++++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100755 cocoa/compile-xib.sh create mode 100755 cocoa/extract-strings.sh (limited to 'cocoa') diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 002dc4872..04adf3a9e 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -154,15 +154,23 @@ $$(OBJROOT)/$(1).lproj: $(2) $(Q)cp -pLR $(2) $$@ endef +# compile_xib (xib) (lang) define compile_xib -R_RESOURCES += $$(OBJROOT)/$(1:.xib=.nib) -$$(OBJROOT)/$(1:.xib=.nib): cocoa/res/$(1) $$(OBJROOT)/created - $(VQ)echo Compiling XIB: $$< - $(Q)ibtool $$< --compile $$@ +$$(OBJROOT)/$(2).lproj: $$(OBJROOT)/$(2).lproj/$(1:.xib=.nib) + +$$(OBJROOT)/$(2).lproj/$(1:.xib=.nib): cocoa/res/$(1) $$(OBJROOT)/created + $(VQ)echo Compiling XIB $(1) for language $(2) + $(Q)mkdir -p $$(OBJROOT)/$(2).lproj + $(Q)cocoa/compile-xib.sh cocoa/res/$(1) $(2) $$@ + +ifeq ($(wildcard cocoa/res/$(2).lproj/$(1).strings), cocoa/res/$(2).lproj/$(1).strings) +$$(OBJROOT)/$(2).lproj/$(1:.xib=.nib): cocoa/res/$(2).lproj/$(1).strings +endif + endef $(foreach lang,$(LANGUAGES),$(eval $(call make_lproj,$(lang),$(addprefix cocoa/res/$(lang).lproj/,$(LOCALIZED_RESOURCES))))) -$(foreach xib,$(S_XIBS),$(eval $(call compile_xib,$(xib)))) +$(foreach lang,$(LANGUAGES),$(foreach xib,$(S_XIBS),$(eval $(call compile_xib,$(xib),$(lang))))) NetSurf.app: NetSurf cocoa/Makefile.target $(R_RESOURCES) NetSurf.app/Contents/Info.plist $(VQ)echo Assembling NetSurf.app bundle diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj index 1e698f6db..5afabee11 100644 --- a/cocoa/NetSurf.xcodeproj/project.pbxproj +++ b/cocoa/NetSurf.xcodeproj/project.pbxproj @@ -174,6 +174,8 @@ 261DB23313180CD600C59F12 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; 261DB23413180CE000C59F12 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = ""; }; 261DB23513180CEE00C59F12 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; + 261DB24F1318444F00C59F12 /* compile-xib.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "compile-xib.sh"; sourceTree = ""; }; + 261DB2501318444F00C59F12 /* extract-strings.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "extract-strings.sh"; sourceTree = ""; }; 2622F1D512DCD84600CD5A62 /* TreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeView.h; sourceTree = ""; }; 2622F1D612DCD84600CD5A62 /* TreeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TreeView.m; sourceTree = ""; }; 2625095012F72A8F0090D236 /* PreferencesWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = ""; }; @@ -529,6 +531,15 @@ path = ../utils; sourceTree = SOURCE_ROOT; }; + 261DB24E1318443500C59F12 /* Tools */ = { + isa = PBXGroup; + children = ( + 261DB24F1318444F00C59F12 /* compile-xib.sh */, + 261DB2501318444F00C59F12 /* extract-strings.sh */, + ); + name = Tools; + sourceTree = ""; + }; 263629B212F69A080048542C /* Makefiles */ = { isa = PBXGroup; children = ( @@ -795,6 +806,7 @@ 265F303F12D6637E0048B600 /* Cocoa Frontend */, 26CDD23E12E743A3004FC66B /* NetSurf */, 263629B212F69A080048542C /* Makefiles */, + 261DB24E1318443500C59F12 /* Tools */, 19C28FACFE9D520D11CA2CBB /* Products */, ); name = Untitled; diff --git a/cocoa/compile-xib.sh b/cocoa/compile-xib.sh new file mode 100755 index 000000000..264d87761 --- /dev/null +++ b/cocoa/compile-xib.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# call: compile-xib.sh [xib file] [language] [(optional output nib file)] +DIR=`dirname "$1"` +XIB=`basename -s .xib "$1"` + +STRINGS_FILE="$DIR/$2.lproj/$XIB.xib.strings" +TRANSLATE="" +if [ -f $STRINGS_FILE ] +then + TRANSLATE="--strings-file $STRINGS_FILE" +fi + +OUTPUT="$2.$XIB.nib" + +if [ "x$3" != "x" ] +then + OUTPUT="$3" +fi + +exec ibtool $TRANSLATE --compile $OUTPUT $1 diff --git a/cocoa/extract-strings.sh b/cocoa/extract-strings.sh new file mode 100755 index 000000000..c3f582619 --- /dev/null +++ b/cocoa/extract-strings.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +for i in $1/*.xib +do + xib=`basename "$i"` + strings="$2/$xib.strings" + + ibtool "$i" --generate-strings-file "$strings" +done + + -- cgit v1.2.3