Skip to content

Instantly share code, notes, and snippets.

@BlackMac
Created March 25, 2010 13:37
Show Gist options
  • Save BlackMac/343556 to your computer and use it in GitHub Desktop.
Save BlackMac/343556 to your computer and use it in GitHub Desktop.
XCode generate xib files from strings files with translation
#!/usr/bin/php
<?
/**
* @license MIT
*/
$target='de.lproj';
$source='en.lproj';
$handle = opendir('de.lproj');
while (false !== ($file = readdir($handle))) {
if (substr($file,-8)==".strings") {
$file_name=substr($file,0,-8);
$strings_file=$target.'/'.$file;
$target_xib=$target.'/'.$file_name.'.xib';
$source_xib=$source.'/'.$file_name.'.xib';
if (file_exists($source_xib)) {
$target_modified=0;
$strings_modified = filemtime($strings_file);
if (file_exists($target_xib)) {
$target_modified = filemtime($target_xib);
}
if ($target_modified<$strings_modified) {
$command=sprintf('ibtool --strings-file "%s" --write "%s" "%s"',$strings_file, $target_xib, $source_xib);
echo "Building $target_xib! \n";
exec($command);
} else {
echo "Skipping $target_xib! \n";
}
}
//echo $command."\n\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment