Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first basic i18n support for webpage #70

Merged
merged 5 commits into from
Jul 20, 2023
Merged

Conversation

samuellvo
Copy link
Collaborator

No description provided.

…asic i18n for now

implements MessageSource to do so
Copy link
Contributor

@breed breed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good try. for the HTML files, we can just translate the HTML. there is a way to do resource translation. we do need message translation for the "bad password" message a little lower down in postOauthToken()

@@ -156,12 +161,20 @@ private CredentialAccount convertAccount2CredentialAccount(Account a) {

@GetMapping("/oauth/authorize")
String getOauthAuthorize(@RequestParam String client_id, @RequestParam String redirect_uri,
@RequestParam(required = false, defaultValue = "") String error) throws IOException {
@RequestParam(required = false, defaultValue = "") String error, @RequestHeader("Accept" +
"-Language") String acceptLanguage) throws IOException {
try (var is = AppController.class.getResourceAsStream("/static/oauth/authorize.html")) {
var authorizePage = new String(is.readAllBytes());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be using thyme here instead of getResourceAsStream

Locale userLocale = Locale.forLanguageTag(acceptLanguage);
authorizePage = authorizePage.replace("authorize_error",
messageSource.getMessage("authorizeError", null, userLocale));
authorizePage = authorizePage.replace("Email", messageSource.getMessage("email", null, userLocale));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing the replace() for authorize_error is sketchy but unlikely to collide with normal text. Email may appear in multiple places. that is why we need to use a thyme template

@samuellvo samuellvo merged commit 1e6f74f into main Jul 20, 2023
1 check passed
@samuellvo samuellvo deleted the Internationalization branch July 20, 2023 04:10
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.

2 participants