"Functions used in place of NSLocalizedString" option does not work.

Issue #101 resolved
Brian Dorfman created an issue

The "Unused Translation" and "Missing Translation" rules both have a "Functions used in place of NSLocalizedString" however this option does not actually seem to do anything. Our project is adding our own macro that has the same signature as NSLocalizedString but routes differently (to our own framework's bundle instead of to the main bundle). However, even after providing the new macro's name, Faux Pas continues to complain that there are unused translations in our project.

Additionally, the "Uncommented localized string" and "UI String not localized" rules should both have the same option to add extra macro names, but do not.

This branch of our project has our in-progress localization effort in it, and you can run Faux Pas there to see the issue: https://github.com/stripe/stripe-ios/tree/bdorfman-localization

Comments (4)

  1. Ali Rantakari repo owner

    Thanks for reporting this.

    The problem here is that the “Functions used in place of NSLocalizedString” (localizedStringRoutines) option only applies to functions, and not to “function-like” macros. This is because the AST Faux Pas inspects has gone through the "C preprocessor" step already, and macro expansions have been performed.

    If you use an inline function instead of a macro, this option should work:

    static inline NSString * _Nonnull STPLocalizedString(NSString* _Nonnull key, NSString * _Nullable __unused comment) {
        return [STPLocalizationUtils localizedStripeStringForKey:key];
    }
    
  2. Ali Rantakari repo owner

    Additionally, the "Uncommented localized string" and "UI String not localized" rules should both have the same option to add extra macro names, but do not.

    I have opened issue #102 to track this.

  3. Brian Dorfman reporter

    Ah I see, sorry about my confusion. I will change to using an actual function instead of a macro. Thank you for your quick response!

  4. Log in to comment