title: iOS Localization - Updating Localizable.strings with just new strings
body: <p>I have searched <em>Google</em> and <em>StackOverflow</em> and still have no clear answer on an easy and automated way of doing this but here is the scenario:</p>
  
  <ol>
  <li>I have an app with 1000 strings localized into  en, fr, de, es, it.</li>
  <li>I build a new feature that makes 10 distinctly new <code>NSLocalizedString()</code> keys.</li>
  <li>I just want those 10 new strings appended onto the ends of the files:
  
  <ul>
  <li>en.lproj/Localizable.strings</li>
  <li>fr.lproj/Localizable.strings</li>
  <li>es.lproj/Localizable.strings</li>
  <li>de.lproj/Localizable.strings</li>
  <li>it.lproj/Localizable.strings</li>
  </ul></li>
  </ol>
  
  <p><code>genstrings</code> will retrieve all 1010 distinct strings. This is a pain since I'll need to "needle in a haystack" find those 10 strings every time I do an update.</p>
  
  <p><strong>UPDATE 19-SEP-2014 -- XCode 6</strong> - Apple has finally released support for XLIFF export and import of your .strings files
  <a href="https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_6_0.html#//apple_ref/doc/uid/TP40014509-SW5" rel="noreferrer" title="Whats New in XCode6? Localisation">Whats new in XCode 6? Localisation</a></p>
  
  <p><strong>Linguan (v1.1.3)</strong> whilst it is a lovely tool most of the time, it is starting to be a tool in the other sense. It merges the changes but some strings aren't matching correctly when it merges, so everytime it does a Scan Sources it creates 100 new duplicate keys as well as the 10 strings I am after so it is making more work.</p>
  
  <p><strong>FileMerge</strong> As suggested below try doing a diff between old and new versions of the <code>genstrings</code> output files. The <code>genstrings</code> output has the strings sorted alphabetically so 10 strings scattered throughout 1000 means that there are 200 differences to review. it keeps matching the <code>/*...*/</code> and the <code>"..." = "..."</code> and saying that the <code>...</code> has been updated. It hasn't been updated, just shifted to a new location in the file. More and more it is looking like I am going to have to write a custom tool. </p>
  
  <p><strong>MacHG + FileMerge</strong> on a side note, for some strange reason doesn't like doing diffs out of the repository with the working copy of Localizable.strings. Both the left and right panes appear empty. 
  <em>UPDATE:</em> Turns out variations in some changesets being saved as UTF-16 and some as UTF-8 are screwing with it being able to do a proper diff.</p>
  
  <p><strong>Bash Script + FileMerge</strong> I have written the following script to help maintain my english reference file after each time I add new <code>NSLocalizedString</code> entries:</p>
  
  <pre><code>#LOCALISATION UPDATE SCRIPT
  #
  #This will create a temporary copy of the current 'en' reference file then generate the 
  #latest reference file using the 'genstrings' tool. Finally forcing FileMerge to launch 
  #and diff the changes.
  #
  #Last Updated: 2014-JAN-06
  #Author(s): Josh Wilson
  
  clear
  #assuming this script is run from $SRCROOT
  
  #Backup Existing 'en' reference
  cp "en.lproj/Localizable.strings" "en.lproj/Localizable-src.strings"
  
  #Scan source files for 'NSLocalizableString' macros
  genstrings -q -u -o en.lproj Classes/*.{m,mm}
  genstrings -q -u -a -o en.lproj Classes/iPad/*.{m,mm}
  genstrings -q -u -a -o en.lproj Classes/iPhone/*.{m,mm}
  
  #Force FileMerge to launch and diff the update (NOTE: piping to cat forces GUI to open)
  opendiff "en.lproj/Localizable-src.strings" "en.lproj/Localizable.strings" | cat
  
  #Cleanup up temporary file
  rm "en.lproj/Localizable-src.strings"
  </code></pre>
  
  <p>But this only updates the EN file and I am lacking a way of having the other language files updated with the new keys. This one has been good for instances where I don't have an english word as the key and genstrings bombs my 
  <code>"welcome_message" = "Welcome!"</code> with <code>"welcome_message" = "welcome_message"</code></p>
  
  <p><strong>POEditor</strong> <a href="http://poeditor.com/" rel="noreferrer">http://poeditor.com/</a>. This is an online tool and subscription based after 1000 strings. Seems to work well but it would be good if there was a non subscription based tool.</p>
  
  <p><strong>Traducto Pro</strong> Seems to do an alright job of integrating with XCode and extracting the strings and merging things together. But it is impossible to get anything back out of it until it is fully translated so you are coerced into using their translation services.</p>
  
  <p>Surely this functionality has been implemented before. How does Apple keep their Apps localised?</p>
  
  <p>Script junkies, I call upon thee! iOS development has been going on for some time now and localisation is kind of common, surely there is a mature solution to this by now?</p>
  
  <p><strong>Python Script</strong> <a href="https://github.com/ndfred/xcode-tools/blob/master/update_strings.py" rel="noreferrer">update_strings.py</a>: <em>Stackoverflow</em> finally recommended a related question and the python script in this answer <a href="https://stackoverflow.com/a/10196327/622276">Best practice using NSLocalizedString</a> looks promising...</p>
  
  <p>Tested it and in its current form (31-MAY-2013) it doesn't handle multiline comments if you have duplicate comments entries (expects single line comments).</p>
  
  <p>Might just need to tweak the regex's a bit.</p>