SwiftGen / SwiftGen

The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[strings] File header used as first localization comment

giofid opened this issue · comments

I have a simple Tutorial.strings file

/* 
  Tutorial.strings
  MyCompany

  Created by John Doe on 11/07/23.
  
*/

"skip_button_title" = "SKIP";
"start_button_title" = "START";

My generated Strings+Generated.strings file contains the file header as comment of the first localization.


internal enum L10n {
  internal enum Tutorial {
    /// Tutorial.strings
    ///   MyCompany
    /// 
    ///   Created by John Doe on 11/07/23.
    internal static let skipButtonTitle = L10n.tr("Tutorial", "skip_button_title", fallback: "SKIP")
    /// START
    internal static let startButtonTitle = L10n.tr("Tutorial", "start_button_title", fallback: "START")
  }
}

@giofid Just remove the header from the strings file and everything will be fine

Thank you @AhmedZaghloul19. Although remove the header is a possible workaround, I think a better solution could be ignore the comment if there is an empty new line between the string and the comment.

I do not think we can rely on the fact that the first comment in a localisation file can be ignored because it could be the documentation information for the first localized key.

In a .strings files, comments are here to given context information for a key. I think that using comments to provide a "file header" like in some source code may not a good practice in this context (even if Xcode generate this header on file creation...).

The best option right now is to follow @AhmedZaghloul19 suggestion.

Otherwise, we would gladly accept any contribution to handle this case if you manage to implement this.