Last active
September 27, 2015 16:28
-
-
Save richardbuckle/1298850 to your computer and use it in GitHub Desktop.
VERY quick and dirty regex to hunt for string literals that may need to be localised
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(?<!Path:|Key:|NSLocalizedString\(|NibName:|NibNamed:|imageNamed:|PathComponent:|xpathQuery:|initForModel:|initWithDomain:|predicateWithFormat:|setDateFormat:|fontWithName:|entities:|sortBy:|NSClassFromString\(|NSLog\(|DLog\(|ALog\(|DebugLogging\()\s*(?!@"%@"|@"%d")@".+" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation:
The conceptual template is:
(?<!foo|bar)
is negative look-behind for "foo
orbar
". It eliminates any matches preceded byfoo
orbar
.(?!foo|bar)
is negative look-ahead for "foo
orbar
". It eliminates any matches followed byfoo
orbar
.The basic idea is to find string literals, eliminating the common cases of
@"%@"
and@"%d"
and eliminating typical Cocoa method and function calls that indicate a non-user-visible string.With a real-life project, this reduced the number of hits from ~1500 to ~400.
I used BBEdit to search the whole source tree with a filter for Cocoa files (extensions
m
,mm
,h
andhh
).