konrad1977 / loco

A linter for Swift Localizations
MIT License
73 stars 2 forks source link

Custom Localised Strings pattern #5

Closed romaHerman closed 1 year ago

romaHerman commented 1 year ago

Hi @konrad1977
Creating a separate issue

I did update to the latest version. It doesn't coght all the strings for me. I was able to fix this by altering the RegexPattern file like this:

   static var sourceRegex: String {
        buildSourceRegex(
          [
            "\\.navigationTitle",
            "Label",
            "DatePicker",
            "Text",
            "Picker",
            "Button",
            "Toggle",
            "LocalizedStringKey",
            "NSLocalizedString",
            "String\\(localized:",
            "MyLocalizedString\\(",
          ]
        )
    }

also, I was trying to add a reg exps but failed for now for such cases: let arrayOfLocalizedKeys = ["key_1", "key_2"]; let key = resourceAvailable ? "key_1" : "key_2"; enum States: String { case online = "online_key" case offline = "ofline_key" }

or maybe there is a way to suppress individual strings.

konrad1977 commented 1 year ago

Could you paste a bit of your code. You can mask variable and function names. Just show me something that doesn't get caught.

romaHerman commented 1 year ago

this doesn't get caught

let subtitleKey = info.hasItem ? "absence.edit_details_instructions" : "absence.details_instructions"
let action_title = status ? MyLocalizedString("messenger.revoke_access") : MyLocalizedString("messenger.promote")
let key = pinned ? "news_pin_success" : "news_unpin_success"

i wonder now that maybe it's the dot in the key name

also system permissions but that's a minor one

"NSCalendarsUsageDescription" = "This app need to access your calendar";

also, I have some keys which I'd like to suppress but that's also a minor thing. They arrive from the server as a key.

konrad1977 commented 1 year ago

Thanks I'll look into it.

romaHerman commented 1 year ago

Thanks a lot

konrad1977 commented 1 year ago

There is a temporary fix up now. This will include commented out and empty strings. Its not performant but should work for you.

romaHerman commented 1 year ago

Thanks a lot! It works now