summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-02-25 21:50:21 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-02-25 21:50:21 +0000
commitde74250a3e0917cad8dbd163b854b3e6b4bfbee9 (patch)
tree5fedd55620fbd9089f103503fabda0670a3c365e
parentb1a2212a95b9ecc324da1fad679b596286a04bbe (diff)
downloadnetsurf-de74250a3e0917cad8dbd163b854b3e6b4bfbee9.tar.gz
netsurf-de74250a3e0917cad8dbd163b854b3e6b4bfbee9.tar.bz2
Building translated nib files if strings file exist.
svn path=/trunk/netsurf/; revision=11802
-rw-r--r--cocoa/Makefile.target18
-rw-r--r--cocoa/NetSurf.xcodeproj/project.pbxproj12
-rwxr-xr-xcocoa/compile-xib.sh20
-rwxr-xr-xcocoa/extract-strings.sh11
4 files changed, 56 insertions, 5 deletions
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 = "<group>"; };
261DB23413180CE000C59F12 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
261DB23513180CEE00C59F12 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
+ 261DB24F1318444F00C59F12 /* compile-xib.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "compile-xib.sh"; sourceTree = "<group>"; };
+ 261DB2501318444F00C59F12 /* extract-strings.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "extract-strings.sh"; sourceTree = "<group>"; };
2622F1D512DCD84600CD5A62 /* TreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeView.h; sourceTree = "<group>"; };
2622F1D612DCD84600CD5A62 /* TreeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TreeView.m; sourceTree = "<group>"; };
2625095012F72A8F0090D236 /* PreferencesWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = "<group>"; };
@@ -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 = "<group>";
+ };
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
+
+