-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make i18n method names configurable #3
Comments
Here is, what my I18n traits typically look like: trait I18nMarker {
def marktr(msgid: String): String = msgid
def marktrc(context: String, msgid: String): String = msgid
}
trait I18n extends I18nMarker {
def tr(msgid: String, params: Any*): String
def trn(msgid: String, msgidPlural: String, n: Long, params: Any*): String
def trc(context: String, msgid: String, params: Any*): String
def trcn(context: String, msgid: String, msgidPlural: String, n: Long, params: Any*): String
def locale: Locale
def preparetr(msgid: String, params: Any*): PreparedI18n
}
trait PreparedI18n {
def tr: String
def notr: String
}
object I18n extends I18nMarker {
def apply[T: ClassTag]: I18n = apply(Locale.getDefault)
def apply[T: ClassTag](locale: Locale): I18n = ???
} The preparetr is a convenience thing, which encapsulates the message and params and provides the formatted messages in translated ( |
Sorry for not implementing what you need earlier. Please see the new README: If there's anything, please let me know. |
Thank you very much. Can there be more than one method for each type of message demarcation? E.g. the |
I'm curious: What's your use case with that feature? Actually, So I think you can do like this: For example, you have When you want to extract i18n strings, use this
After extracting you get a i18n.pot file. Then change You only need to merge (with Poedit, for example) the 2 files together to get the final result. |
I've just released version 1.2. |
The feature is required, to mark strings for translation without actually translating it. This can be necessary e.g. if you define the string before you have access to the translator, e.g. when using it in an object or some "static" location (like an Java enum). It is also handy, if you use the untranslated string internally, e.g. in the database, but want to translate it's presentation. Of course, I can run the compiler with the plugin multiple times and can merge the catalogs, but this is a lot of extra work (for the compiler and in the toolchain). As xgettext directly supports this, I think, it could be a feature of scala-xgettext too. |
On top of this, there is the
It's also useful to reuse the |
Thanks for the explanation. |
Great. Thank you very much. |
In Java/Scala-land, I would argue,
tr
,trn
, ... are more common, at least in my projects. I currently still use xgettext which accept the method names with the-k
option. Using scala-xgettext is not possible because of incompatible hardcoded method names.The text was updated successfully, but these errors were encountered: