Building translated nib files if strings file exist.

svn path=/trunk/netsurf/; revision=11802
This commit is contained in:
Sven Weidauer 2011-02-25 21:50:21 +00:00
parent b1a2212a95
commit de74250a3e
4 changed files with 56 additions and 5 deletions

View File

@ -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

View File

@ -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;

20
cocoa/compile-xib.sh Executable file
View File

@ -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

11
cocoa/extract-strings.sh Executable file
View File

@ -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