Lachtan
Lachtan

Reputation: 5172

Can you generate properties from comments rather than keys in Localizable.strings using SwiftGen?

Is there a way to generate properties from comments, rather than localization keys using SwiftGen?

Here's an example for better illustration of what I mean:

Lozalizable.strings:

...
/* file_detail.button.download */
"T00014" = "Download";
...

Strings+Generated.swift:

internal enum L10n {
    internal enum FileDetail {
        internal enum Button {
            /// Download
            internal static let download = L10n.tr("Localizable", "T00014")
        }
    }
}

Upvotes: 0

Views: 80

Answers (1)

You can write a self-written solution for this. If you want to use a comment instead of a key, write your .stencil for this and use it in SwiftGen. Some days before, I wrote my solution for localization, where I wrote a .stencil file you could check for inspiration.

https://github.com/idapgroup/xcode-localization-parser

Upvotes: 0

Related Questions