dral3x / StringsLint

📱Ensure your localized strings are complete and never unused 👍
MIT License
68 stars 10 forks source link

Wrapper around NSLocalizedString causes script to say no strings are used #14

Open TimAEllis opened 3 years ago

TimAEllis commented 3 years ago

NSLocalizedString seems a little cumbersome for me to use since I don't include a comment with my strings. So I have a wrapper function, like so:

public func localeString(_ string: String) -> String {
    return NSLocalizedString(string, comment: "")
}

However, this script then claims that all my localized strings are unused when clearer they are. Is there any way we can provide it with a string to look for, in addition to the pre-existing NSLocalizedString?

dral3x commented 3 years ago

Hi @TimAEllis ! Sorry for taking so long to respond, I missed Github's notification 😢

I have the feeling the tool is missing some customization to allow the detection of custom swift code like your function localeString(_:).

You can give it a try, working on SwiftParserConfiguration and SwiftParser classes. Tests will help you along the way 🙂

dral3x commented 3 years ago

@TimAEllis what about something like this https://github.com/dral3x/StringsLint/compare/custom-swift-localize-function#diff-41a7cd1296e1aee684346e698c787b394a9b7374c6a31e6225c46ad32e7dff95R186