On 04. 08. 20 22:57, Christian Köberl wrote:
> Hi Martin!
>
> Here are some remarks to your answers.
>
> > * There should be the ability to define all messages in a
> properties
> > (or PO, or XLIFF) file - also the default ones. This is
> needed for
> > translation systems to work properly.
>
> That kind of defeats the purpose of the type-safe message bundles. That
> way we wouldn't be able to validate the messages properly.
>
>
> You could just declare the message in the Java code and provide the text
> like this
>
> AppMessages.java
> @Message
> String hello();
>
> msg.properties
> helllo=Hello
>
This might work, although it could complicate things a little. E.g. we
would have to decide what happens if an interface mixed things up. I've
created
https://github.com/quarkusio/quarkus/issues/17857 to track the
issue.
> With this you could use a translation tool - without that you simply can't.
>
> > An alternative could be exporting/importing those files as a
> build step.
> Well, the interface could be generated but that would not help with
> validation.
>
>
> I thought about generating the base properties file from the Java code
> (not the other way around) so that a translation tool can use it as input.
Sure, this might be useful:
https://github.com/quarkusio/quarkus/issues/17859
>
> The problem with dots is that we use them to split expressions in Qute.
>
>
> I think that would be a nice-to-have (probably also a need-to-have when
> you migrate from another framework or use messages in a multi-app setup).
The bracket notation can be used, i.e.
msg:['app-maintenance.settings.admin-email-label']
>
> Right now, you can use basic control flow constructs to handle similar
> use cases ({#if}). In theory, nothing prevents you from using
> MessageFormat directly in your messages, but since it is not
> thread-safe
> you would need to synchronize externally.
>
>
> {#if} does not work for pluralization (see Russian for an example
>
http://www.russianlessons.net/lessons/lesson11_main.php).
My point is that these constructs can be used together with nested
messages. Take a look at this test, which tries to solve the same
problem as described in
https://docs.oracle.com/javase/tutorial/i18n/format/choiceFormat.html:
https://github.com/quarkusio/quarkus/pull/17855/files#diff-18e70586ac7ef2a7a27493eb49d40800e1f3ddda2a9bb9e019ecce19c90a7168R34-R43
Of course, we should improve the UX, i.e. support multi-line messages in
the properties files. But in general, this way you can handle any
"choice" problem in one bundle without the need for some special constructs.
>
> > * There should be the ability to adapt/extend the loading of
> messages
> > via your own code. Most Translation systems (like Weblate
> > <
https://weblate.org/ <
https://weblate.org/>>) have a REST
> API where you can get your
> > translations on demand. With this ability the app developer
> can load
> > the translations from the API so the translator can see the
> > immediate effect of her translations in the running application.
> > This is a small library doing this for Spring's MessageSource
> with
> > Zanata:
https://github.com/porscheinformatik/zanata-spring
> <
https://github.com/porscheinformatik/zanata-spring>
>
> That's probably beyond the capabilities we would like to introduce at
> this stage.
>
>
> Maybe this can be added later but it would be great to have extension
> points for app developers in the API.
Yep, we could definitely add more stuff. Feel free to open issues and
send pull requests :-).
>
>
> Please have a look at other framework's approaches to localization to
> see the needs for applications (locale fallback, pluralization,
> combining bundles, loading translations from the database, etc.). I've
> started by dev career in 1999 with implementing message bundles/i18n in
> our in-house framework and am still learning new stuff in this area
> every other month.
Yes, localization and internationalization is a complex topic. But like
I mentioned before, the type-safe messages are not intended to cover all
complex i18n use cases in the world. Instead, it provides a type-safe
alternative to solve common tasks. Anyway, Quarkus is OSS so let's work
on it together and add one feature at a time ;-).
>
> Cheers,
> Chris
>
> --
> You received this message because you are subscribed to the Google
> Groups "Quarkus Development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
quarkus-dev...@googlegroups.com
> <mailto:
quarkus-dev...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/quarkus-dev/5e4b1238-1f5a-4dc0-94e8-d86f45c514e9o%40googlegroups.com
> <
https://groups.google.com/d/msgid/quarkus-dev/5e4b1238-1f5a-4dc0-94e8-d86f45c514e9o%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Martin Kouba