Localize-Swift
Localize-Swift copied to clipboard
Adding support for comments
Thanks @Sufi-Al-Hussaini. I like this syntax a lot!
We will need to add this to the Swift genstrings script too (the python string will be eventually deprecated).
You're welcome @marmelroy . And thank you for this cool library. I'm sorry I missed the swift script. I will look into it.
Meanwhile, I was wondering if it would be better to have a chained comment()
extension to String
.
That way we could support comments on localizedFormat()
as well, like:
textLabel.text = "Hello World".localized().comment("some comment")
It would be great to add comments to all localized strings
Could you also provide an opportunity to parse args that are passed to localizedFormat function and add them to comment, or something like this?
My 2¢
If convert localized()
func to calculated property localized
, then it would be nice to see func localized(with comment: String) -> String
, that would be perfect to #53 .
It would be nice to write smth like this: string.localized(with: "Comment", using: "TableName", in: bundle)
.
@nekrich - I'd go with "some string".localized("comment")
. This way you'd have a syntax like this:
let localizedTitle = "Some title".localized("title for a view")
// read as: some title string is localized title for a view
The table name can be added as a second parameter with a from
label:
let localizedTitle = "Some title".localized("title for a view", from: "some table")
// read as: some title is localized title for a view from some table