Search code examples
xcodelocalizationlocalizable.strings

Delete unused ressources from Localizable.strings


I'm using BartyCrouch to maintain an up-to-date localized project. My project is currently translated in 4 different languages, and I'm going to add some new languages. My issue is that my base Localizable.strings file has about 200-300 resources, even though there are probably less than 100 currently used in the project.

I'm looking for the best way to remove the un-referenced localized strings in the project, all while keeping the currently localized values. Is there any native solution or do I have to use a third party? And if so, is there anything automatic?


Solution

  • Well, I definitely didn't look hard enough. I think it's worth posting an answer instead of deleting the question because I don't think the answer is on Stackoverflow yet.

    https://github.com/ijoshsmith/abandoned-strings

    This little gem will do exactly this. Easy to use. Simply download the zip file, use the Terminal to go into the "AbandonedStrings" folder containing a single "main.swift" file. Then, on the terminal, enter: ./main.swift /the/path/to/your/project

    This will display a list of all the unused ressources. Then, if you also want the script to delete them, simply add "write" at the end of the command.

    Watch out though: it will delete all the Storyboard localized ressources, so commit your project before and simply discard the changes.