Unused localized strings clean up from a Strings file – onlinecode
In this post we will give you information about Unused localized strings clean up from a Strings file – onlinecode. Hear we will give you detail about Unused localized strings clean up from a Strings file – onlinecodeAnd how to use it also give you demo for it if it is necessary.
Strings files are used for localization in iOS and MacOS apps. These files can grow over time and make it hard to maintain. It’s easy to end up with a lot of unused localized strings. Although this is not an issue for performance or slowing you down a lot, it is kind of nice to keep your resource files clean.
Xcode does not provide an out of the box solution for this. However, we have a great community and quite some tools exist to solve this issue. I dived in and took a look at NSLocalizer, Abandoned Strings, and this medium blog post. From the two Github projects, the one from Josh Smith gave the best results.
Before we dive in, it’s worth mentioning that the medium blog post from Gino Wu provides a nice way to integrate it into your Xcode build process. However, in my opinion, this is not something you need to integrate and run that often, slowing down your build process for each run. It’s unlikely that you end up with unused strings quite often, so running it manually every now and then should be enough.
Therefore, let’s dive into the Abandoned Strings terminal tool.
The tool will show a list of unused localized strings after running the command
Finding unused resource strings
The first step is to create an executable from the Github project. Download the project from github.com/ijoshsmith/abandoned-strings, build it by using Xcode and find the executable in the products folder.
Right-click on the executable and select “Show in Finder” to open the containing folder. This will be your base path to use in the terminal. You can use the
cd command to change the terminal directory. After that, run the following command:
$ ./AbandonedStrings /Users/your-username/path/to/source/code
Removing unused localized strings
The tool will show a list of unused localized strings after running the command:
You can use this list to remove them from your project. Unfortunately, this is still a manual process and can be quite some work if you have a lot of unused strings. However, this will improve if you run this tool more often.
What is included in the results?
The tool takes
.strings files in your project and walks through all defined keys. Say that the strings file contains a key called
home.button.title. The tool will take this key and validates whether any
.jsbundle contains a reference. If not, it will consider that key as unused.
Although this tool is great to keep your string files clean, you have to run it manually yourself and remind yourself to run it every now and then. However, as you’re unlikely to introduce unused strings quite often, it’s more than fine to not run it every day.
<!– Disable cross link to Medium
Also published on Medium.
Hope this code and post will helped you for implement Unused localized strings clean up from a Strings file – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs