Skip to content

Commit

Permalink
I18N: do not use deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Oct 27, 2023
1 parent 48a623d commit 12085c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testChangeLanguage() {
.param("l", "fr")
.post("/lang").then()
.statusCode(200)
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.body(Matchers.is("fr"));
RestAssured
.given()
Expand Down Expand Up @@ -145,31 +145,31 @@ public void testQuteLanguage() {
.body(Matchers.is("english message"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/qute").then()
.statusCode(200)
.body(Matchers.is("message français"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/qute-uni").then()
.statusCode(200)
.body(Matchers.is("message français"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/qute-cs").then()
.statusCode(200)
.body(Matchers.is("message français"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/qute-response").then()
.statusCode(200)
.body(Matchers.is("message français"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/qute-rest-response").then()
.statusCode(200)
.body(Matchers.is("message français"));
Expand All @@ -184,7 +184,7 @@ public void testTypeUnsafeLanguage() {
"english message\nenglish STEF message\nenglish message\nenglish message\nenglish message with code\nenglish message with code\nenglish STEF message\nmissing"));
RestAssured
.given()
.cookie(I18N.LANGUAGE_COOKIE_NAME, "fr")
.cookie(I18N.LOCALE_COOKIE_NAME, "fr")
.get("/type-unsafe").then()
.statusCode(200)
.body(Matchers.is(
Expand All @@ -195,7 +195,6 @@ public void testTypeUnsafeLanguage() {
.param("l", "de")
.post("/lang").then()
.statusCode(500);

}

@Test
Expand Down Expand Up @@ -261,14 +260,14 @@ public String validation(@NotEmpty @RestForm String param) {

@Path("/lang")
public String lang() {
return i18n.get();
return i18n.getLanguage();
}

@POST
@Path("/lang")
public String lang(@RestForm String l) {
i18n.set(l);
return i18n.get();
return i18n.getLanguage();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void setTemplateLocaleAndRenderArgs(TemplateInstance template) {
template.data(entry.getKey(), entry.getValue());
}
// set the proper locale
template.setAttribute(MessageBundles.ATTRIBUTE_LOCALE, i18n.get());
template.setAttribute(MessageBundles.ATTRIBUTE_LOCALE, i18n.getLanguage());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void setLanguageCookie() {
HttpServerResponse response = request.response();
if (localeOverridden && !response.headWritten()) {
response.addCookie(
io.vertx.core.http.Cookie.cookie(LANGUAGE_COOKIE_NAME, locale.toString())
io.vertx.core.http.Cookie.cookie(LOCALE_COOKIE_NAME, locale.toString())
.setPath("/")
.setSameSite(CookieSameSite.LAX)
.setSecure(request.isSSL()));
Expand Down

0 comments on commit 12085c9

Please sign in to comment.