Skip to content

Commit 8b1ff9c

Browse files
committed
Update nightly build script for temporary translation workaround, improve xibLocalizationPostprocessor robustness
1 parent 7848763 commit 8b1ff9c

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

Scripts/nightlybuildscript.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,50 @@ then
4444
exit 1
4545
fi
4646

47+
IBSTRINGSDIR=ibstrings
48+
XIB_BASE="$GIT_DIR/Interfaces/English.lproj"
49+
4750
echo "Cleaning remains of any previous nightly builds..."
4851

4952
# Delete any previous disk images and translation files
5053
rm -f *.dmg &> /dev/null
5154
rm -rf disttemp &> /dev/null
5255
rm -f languagetranslations.zip &> /dev/null
5356
rm -rf languagetranslations &> /dev/null
57+
rm -rf $IBSTRINGSDIR &> /dev/null
5458

55-
echo "Downloading localizations to merge in..."
59+
echo "Creating IB strings files for rekeying..."
60+
mkdir -p $IBSTRINGSDIR/English.lproj
61+
find "$XIB_BASE" \( -name "*.xib" \) | while read FILE; do
62+
printf "\t$(basename ${FILE})\n"
63+
ibtool "$FILE" --export-strings-file "$IBSTRINGSDIR/English.lproj/`basename "$FILE" .xib`.strings"
64+
done
5665

66+
echo "Downloading localizations to merge in..."
5767
# Download the latest language translations, and copy them into the Resources directory
5868
curl http://dev.sequelpro.com/translate/download/sequelpro > languagetranslations.zip
5969
unzip -q languagetranslations.zip -d languagetranslations
70+
71+
echo "Rekeying localization files, translating xibs, merging localizations..."
6072
find languagetranslations/Resources \( -name "*.lproj" \) | while read FILE; do
61-
printf "\tCopying localization: $(basename ${FILE})\n"
62-
cp -R "$FILE" "Sequel Pro.app/Contents/Resources/"
73+
loc=`basename "$FILE"`
74+
mkdir "$IBSTRINGSDIR/$loc"
75+
printf "\tRekeying localization: $loc\n"
76+
find "$FILE" \( -name "*.strings" \) | while read STRFILE; do
77+
file=`basename "$STRFILE" .strings`
78+
printf "\t\tFile: $file\n"
79+
ibkeyfile="$IBSTRINGSDIR/English.lproj/$file.strings"
80+
xibfile="$XIB_BASE/$file.xib"
81+
transfile="$IBSTRINGSDIR/$loc/$file.strings"
82+
if [ -e "$ibkeyfile" ] && [ -e "$xibfile" ]; then
83+
$BUILD_DIR/xibLocalizationPostprocessor "$STRFILE" "$ibkeyfile" "$transfile"
84+
#we no longer need the original file and don't want to copy it
85+
rm -f "$STRFILE"
86+
ibtool "$xibfile" --import-strings-file "$transfile" --compile "languagetranslations/Resources/$loc/$file.nib"
87+
fi
88+
done
89+
printf "\tCopying localization: $loc\n"
90+
cp -R "$FILE" "Sequel Pro.app/Contents/Resources/"
6391
done
6492

6593
echo "Copying nightly icon"

Source/xibLocalizationPostprocessor.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,31 @@ int main(int argc, const char *argv[])
9292
NSDictionary *load_kv_pairs(NSString *input)
9393
{
9494
NSDictionary *result = [NSMutableDictionary dictionary];
95-
__block NSUInteger lineCount = 0;
96-
[input enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
95+
96+
NSUInteger lineCount = 0;
97+
//don't try [NSString enumerateLines...] here. It supports some obscure Unicode line breaks!
98+
for (NSString *line in [input componentsSeparatedByString:@"\n"]) {
9799
lineCount++;
98100

99101
if (line.length == 0 || [line hasPrefix:@"/*"]) {
100-
return;
102+
continue;
101103
}
102104

103105
if ([line hasPrefix:@"\""] && [line hasSuffix:@"\";"]) { // eg: "136.title" = "Quit Library";
104106

105107
NSRange quoteEqualsQuoteRange = [line rangeOfString:@"\" = \""];
106-
if (quoteEqualsQuoteRange.length && NSMaxRange(quoteEqualsQuoteRange) < line.length - 1) {
108+
if (quoteEqualsQuoteRange.location != NSNotFound && quoteEqualsQuoteRange.length && NSMaxRange(quoteEqualsQuoteRange) < line.length - 1) {
107109
NSRange keyRange = NSMakeRange(1,quoteEqualsQuoteRange.location - 1); //the first " is always at pos. 0 (we checked that above)
108110
NSString *key = [line substringWithRange:keyRange];
109111
NSString *value = [line substringFromIndex:NSMaxRange(quoteEqualsQuoteRange)]; // chop off leading: "blah" = "
110112
value = [value substringToIndex:[value length] - 2]; // chop off trailing: ";
111113
[result setValue:value forKey:key];
112-
return;
114+
continue;
113115
}
114116
}
115117

116118
NSLog(@"Warning: skipped garbage trans line %lu, contents: \"%@\"", (unsigned long)lineCount, line);
117-
118-
}];
119+
}
120+
119121
return result;
120122
}

0 commit comments

Comments
 (0)