Localized routes and URL string

Is there a general solution or best practice on how to implement localized string and URL routes in (java) Play! Appendix?

we need such routes:

/ examples / demonstration

/ esempi / dimostrazione

/ przyklady / demonstracji

... (10+ languages)

All URLs naturally pointing to the controller. Examples and action demonstration .

Thanks in advance!

+4
source share
1 answer

Perhaps you can do something like this:

For English:

%{ if (play.i18n.Lang.getLocale().getLanguage().equals("en")) { }% GET /add-new-post Application.addNewPost %{ } }% 

For the Dutch:

 %{ if (play.i18n.Lang.getLocale().getLanguage().equals("nl")) { }% GET /voeg-nieuwe-commentaar Application.addNewPost %{ } }% 

Etc etc.

Credits: http://playframework.wordpress.com/2011/07/15/hidden-features-of-the-play-framework-routes-file/

Good luck.

0
source

Source: https://habr.com/ru/post/1391713/


All Articles