devxoul / UITextView-Placeholder

A missing placeholder for UITextView
MIT License
1.48k stars 259 forks source link

Support localization #52

Closed Idomo closed 6 years ago

Idomo commented 6 years ago

Added NSLocalizedString() when setting the text of the placeholderTextView.

devxoul commented 6 years ago

Why not just using:

textView.placeholder = NSLocalizedString(@"My placeholder", @"");
Idomo commented 6 years ago

@devxoul It's not necessary, but it will indicate that the translation is for the placeholder and not just the word itself (this is the reason the comments are exist and required).

devxoul commented 6 years ago

I mean, why should the text view translate the placeholder text?

Idomo commented 6 years ago

@devxoul Oh, I did it because I'm using the IBDesginable and this is the only way to call NSLocalizedString from there.

devxoul commented 6 years ago

Users can set translated placeholder text if they want. UITextView should not translate the given placeholder.

Idomo commented 6 years ago

@devxoul Why it shouldn't? I want to use IBDesginable to see the placeholder in the storyboard and I want to write less unnecessary code (that I can with this change), If someone doesn't want to translate the placeholders he doesn't have to, It's shouldn't interrupting him or make him do an extra action, it just help to the ones how want to translate the placeholders.

devxoul commented 6 years ago

Because it is implicit and unpredictable. UITextField doesn't work like that. I'd like to keep the behavior as same as the UITextField's placeholder. Imagine if the user doesn't want to translate the text when there is a same localizable string. For example:

Localizable.strings

"OK" = "확인";

MyView.swift

self.textView.placeholder = "OK" // I'd like to display 'OK' but it will translate to '확인'.
Idomo commented 6 years ago

@devxoul Humm I understood now, thanks :)