When a trs"…" is invoked, it:
- Translates the entire Scala interpolation template into a valid ICU translation phrase (which has its own interpolation syntax), and either finds it in the DB or adds it to the DB.
- It finds the translated target-language version of the source-language ICU phrase once the translator has provided it.
- It fills the template using the provided type-safe parameters, and including complex args like TrPlural objects, and already translated interpolants.
So almost none of that can be done by just invoking on a method on the arguments. The only real alternative is to create the content as valid ICU phrase units, and fill them using the conventional function calls that look like:
ICU.translate(locale, "This is an ICU template with interpolants {0}, {1}, etc...", arg0, arg1, ...)
That works fine, but it is a less fluid approach (it is template-then-args, rather than an inline interpolation style), it is typo-prone, doesn’t take full advantage of the compiler for error-avoidance, and it gets really messy when you start using it at scale.
I’m going to bow out of this discussion now. We’d love to use Kotlin over Scala because it is much faster to compile (which is the main knock against Scala), but this feature is a deal breaker and it is clear from this thread that it won’t be coming anytime soon. Good luck to the other interested parties!