Skip to content

Ability to match request locale and use it for templates - #2019

Merged
jknack merged 6 commits into
jooby-project:2.xfrom
imeszaros:locales
Sep 27, 2020
Merged

jknack merged 6 commits into
jooby-project:2.xfrom
imeszaros:locales

Conversation

@imeszaros

Copy link
Copy Markdown
Member

May close #2006

I need to write test cases and test it more, but what do you think?

I didn't find any way to set the locale for rocker and handlebars.

@imeszaros
imeszaros marked this pull request as draft September 24, 2020 00:31
@jknack

jknack commented Sep 24, 2020

Copy link
Copy Markdown
Member

Looks very good.

Comment thread tests/src/test/java/io/jooby/FeaturedTest.java
Comment thread tests/src/test/java/io/jooby/FeaturedTest.java
@imeszaros

Copy link
Copy Markdown
Member Author

I added the tests. I think it's ok but there is a strange behavior I commented above. This language matching concept is not very straightforward for me.

@imeszaros
imeszaros marked this pull request as ready for review September 27, 2020 01:04
@imeszaros

Copy link
Copy Markdown
Member Author

Ok I read through RFC 4647 and actually it's not mandatory that filter returns an ordered list:

If the language priority list (see Section 2.3) contains more than
one range, the content returned is typically ordered in descending
level of preference, but it MAY be unordered, according to the needs
of the application or protocol.

So i read the source of LocaleMatcher found here, and indeed when one of the tags in the priority list is the asterisk (*), it just returns the input list as it is.

@jknack

jknack commented Sep 27, 2020

Copy link
Copy Markdown
Member

just one change and we are ready.

@jknack jknack added this to the 2.9.1 milestone Sep 27, 2020
@jknack
jknack merged commit 3da75f5 into jooby-project:2.x Sep 27, 2020
@imeszaros
imeszaros deleted the locales branch September 28, 2020 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jooby 2.x Pebble Module i18n support

2 participants