BartyCrouch icon indicating copy to clipboard operation
BartyCrouch copied to clipboard

Swift 4 multiline string literals syntax not supported

Open ehamberg opened this issue 6 years ago • 1 comments

(First of all, thanks for a great tool!)

With the following code, only "foo" is picked up by BartyCrouch:

let foo = NSLocalizedString("foo", comment: "foo")
let bar = NSLocalizedString(
    """
    bar
    """,
    comment: "bar")

Note that this is isn't even a multi-line string – it just uses Swift's multiline string literals syntax.

ehamberg avatar Apr 18 '18 19:04 ehamberg

Hi @ehamberg and thank you for opening this issue.

Please note that we are using the genstrings tool from Apple by default to generate .strings-Files from Code. If that doesn't work, we have no possibilities to fix the tool. But there's a successor to the genstrings tool which you can specify to be used by BartyCrouch instead, see this section in the README.

If that also doesn't help though, then the only hope I have for you is that @rockingdice suggested to integrate a third party library for generating .strings-Files rather than the tools from Apple here. In case that's implemented maybe that way we can get support for multiline string literals.

Having all that said, I'm really curious why you're trying to use multiline string literals for translation keys? As far as I know it's considered bad practice to use actual translations as keys, instead one should make unique keys up, like "MY_CONTEXT.FOO". Of course I don't know your use case, but for reference for anybody who might run into the same problem: Please consider using abstract keys and placing actual content into the Localizable.strings file.

Jeehut avatar Apr 20 '18 06:04 Jeehut