Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[strings] File header used as first localization comment #1070

Open
giofid opened this issue Jul 11, 2023 · 3 comments
Open

[strings] File header used as first localization comment #1070

giofid opened this issue Jul 11, 2023 · 3 comments

Comments

@giofid
Copy link

giofid commented Jul 11, 2023

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")
  }
}
@AhmedZaghloul19
Copy link

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

@giofid
Copy link
Author

giofid commented Aug 3, 2023

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.

@Liquidsoul
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants