Skip to content

Instantly share code, notes, and snippets.

@ole
Last active April 4, 2022 06:11
Show Gist options
  • Star 80 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save ole/5007019 to your computer and use it in GitHub Desktop.
Save ole/5007019 to your computer and use it in GitHub Desktop.
Automatically extract translatable strings from Xcode storyboards and update .strings files. Original version by MacRumors forum user mikezang (http://forums.macrumors.com/showpost.php?p=16060008&postcount=4). Slightly updated by Ole Begemann. NOTE: this Gist moved to a regular repo at https://github.com/ole/Storyboard-Strings-Extraction.
# (File moved to https://github.com/ole/Storyboard-Strings-Extraction)
@ole
Copy link
Author

ole commented Feb 21, 2013

The first revision is mikezang's original version of the script. See http://forums.macrumors.com/showpost.php?p=16060008&postcount=4

@ole
Copy link
Author

ole commented Feb 21, 2013

Updated to automatically create the base strings file for each storyboard if it does not exist.

@ole
Copy link
Author

ole commented Feb 21, 2013

@gamabounta
Copy link

Hey.

I tried to use this script but I encountered 2 limitations:

  • Some placeholders strings like % generate errors.
  • I have multiple XX.lproj in my project (for graphics, plist or anything) and instead of looking up for *.lproj at the same level that Base.lproj, the output is copied everywhere.

For really small / non-complex project I guess I'll use it, though.

@esad
Copy link

esad commented Aug 6, 2013

@ole Should Base.lproj strings file be checked into version control?

@masterkain
Copy link

Doesn't seems to work so well on Xcode5 DP6, wiped all my strings content and all the strings content of cocoapods libs.

@Narayane
Copy link

Hi,
same problem than masterkain, clean all MainStoryboard.string files content after a storyboard update.

Here, errors for xcode :
-Iconv: ./myproject/Base.lproj/MainStoryboard.strings.new: No such file or directory
-Rm: ./myproject/Base.lproj/MainStoryboard.strings.new: No such file or directory
-Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

First, I thought to a Base.lproj directory access rights problem. So, I tried to do a "chmod 777" on Base.lproj directory but nothing has changed ...

@xelagc
Copy link

xelagc commented Oct 17, 2013

I doesn't work on Xcode 5. Same problem :(

@ole
Copy link
Author

ole commented Feb 26, 2014

I have updated the script with a fix/workaround for the error that could caused the wiping of existing strings files in Xcode 5. Please see the update to my blog post for details.

@martinmg
Copy link

Works great! Thx a lot

@Spokane-Dude
Copy link

Works somewhat but changed FR, IT and JA files to garbage! Don't have a clue why... :-{

@jehumo
Copy link

jehumo commented Apr 2, 2014

Great script! But still I am wondering if it would be a way to change the way in which apple provides this horrible labor and write something more legible.

For example:
I would like to change this ugly ObjectID = "ccX-24-Hnq";
for a more friendly ViewController="LoginViewController".

In this way any translator would be able to know the context in which that text must be translated.

Thanks for sharing your work!

@Jeehut
Copy link

Jeehut commented Feb 15, 2016

In case anybody comes across this script looking for a solution like this that is working with Xcode 7+:
You might want to checkout BartyCrouch, a command line utility I recently wrote in Swift that does a fairly similar thing. I hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment