darksider
darksider

Reputation: 1030

How to find non localised strings in a swift project

How can I find all strings a project that are not being localised?

My goal is to add support for localisation by generating the XLIFF file, via Editor->Export For Localisation. In order to do that, I first added comment for Localiser where needed in the Storyboard.

Next, I need to find in the code all Strings that do not use NSLocalizedString("...", comment:"..."). Is there a way to find all these strings?

I didn't succeed writing a regex to find them, due to my lack of competence in regex.

My goal is to have a regex like this: [withIdentifier: |NSLocalizedString(]".*"

in order to find all strings surrounded by quotes, and that are not precedeed by some keywords.

I tried with no success using negative look ahead with A regular expression to exclude a word/string

It's not meant for automated replacement, but just to have a quick view if I haven't forgotten some strings.

Thank you very much!

Upvotes: 2

Views: 3186

Answers (1)

Prashant Tukadiya
Prashant Tukadiya

Reputation: 16446

OBJC

There is a possible way that you can find ALL The Strings which are not used by NSLocalizedString

enter image description here

Goto Product -> Analyze

From Left Panel you can see

enter image description here

Where you can find each and every string which are not Localized

On tap on that

XCode will tell you issue

enter image description here

SWIFT3

I am not Sure about solution NOT TESTED

https://medium.com/@pinmadhon/finding-non-nslocalized-strings-in-xcode-8-in-swift-3-or-objc-589ee279a166

Upvotes: 6

Related Questions