Skip to content
Permalink
Browse files

Update nightly build script for temporary translation workaround, imp…

…rove xibLocalizationPostprocessor robustness
  • Loading branch information...
dmoagx committed Mar 9, 2015
1 parent 7848763 commit 8b1ff9c9b8a996ff0c6321e58709c25f0c5763c1
Showing with 40 additions and 10 deletions.
  1. +31 −3 Scripts/nightlybuildscript.sh
  2. +9 −7 Source/xibLocalizationPostprocessor.m
@@ -44,22 +44,50 @@ then
exit 1
fi

IBSTRINGSDIR=ibstrings
XIB_BASE="$GIT_DIR/Interfaces/English.lproj"

echo "Cleaning remains of any previous nightly builds..."

# Delete any previous disk images and translation files
rm -f *.dmg &> /dev/null
rm -rf disttemp &> /dev/null
rm -f languagetranslations.zip &> /dev/null
rm -rf languagetranslations &> /dev/null
rm -rf $IBSTRINGSDIR &> /dev/null

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

echo "Downloading localizations to merge in..."
# Download the latest language translations, and copy them into the Resources directory
curl http://dev.sequelpro.com/translate/download/sequelpro > languagetranslations.zip
unzip -q languagetranslations.zip -d languagetranslations

echo "Rekeying localization files, translating xibs, merging localizations..."
find languagetranslations/Resources \( -name "*.lproj" \) | while read FILE; do
printf "\tCopying localization: $(basename ${FILE})\n"
cp -R "$FILE" "Sequel Pro.app/Contents/Resources/"
loc=`basename "$FILE"`
mkdir "$IBSTRINGSDIR/$loc"
printf "\tRekeying localization: $loc\n"
find "$FILE" \( -name "*.strings" \) | while read STRFILE; do
file=`basename "$STRFILE" .strings`
printf "\t\tFile: $file\n"
ibkeyfile="$IBSTRINGSDIR/English.lproj/$file.strings"
xibfile="$XIB_BASE/$file.xib"
transfile="$IBSTRINGSDIR/$loc/$file.strings"
if [ -e "$ibkeyfile" ] && [ -e "$xibfile" ]; then
$BUILD_DIR/xibLocalizationPostprocessor "$STRFILE" "$ibkeyfile" "$transfile"
#we no longer need the original file and don't want to copy it
rm -f "$STRFILE"
ibtool "$xibfile" --import-strings-file "$transfile" --compile "languagetranslations/Resources/$loc/$file.nib"
fi
done
printf "\tCopying localization: $loc\n"
cp -R "$FILE" "Sequel Pro.app/Contents/Resources/"
done

echo "Copying nightly icon"
@@ -92,29 +92,31 @@ int main(int argc, const char *argv[])
NSDictionary *load_kv_pairs(NSString *input)
{
NSDictionary *result = [NSMutableDictionary dictionary];
__block NSUInteger lineCount = 0;
[input enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {

NSUInteger lineCount = 0;
//don't try [NSString enumerateLines...] here. It supports some obscure Unicode line breaks!
for (NSString *line in [input componentsSeparatedByString:@"\n"]) {
lineCount++;

if (line.length == 0 || [line hasPrefix:@"/*"]) {
return;
continue;
}

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

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

NSLog(@"Warning: skipped garbage trans line %lu, contents: \"%@\"", (unsigned long)lineCount, line);
}];
}

return result;
}

0 comments on commit 8b1ff9c

Please sign in to comment.
You can’t perform that action at this time.