Localize-Swift icon indicating copy to clipboard operation
Localize-Swift copied to clipboard

Adding support for comments

Open hu55a1n1 opened this issue 8 years ago • 5 comments

hu55a1n1 avatar Jun 29 '16 08:06 hu55a1n1

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).

marmelroy avatar Jun 29 '16 08:06 marmelroy

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")

hu55a1n1 avatar Jun 29 '16 09:06 hu55a1n1

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?

piv199 avatar Jun 30 '16 07:06 piv199

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 avatar Oct 09 '16 18:10 nekrich

@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

eimantas avatar Apr 12 '17 05:04 eimantas