Skip to content

Commit e2a53e8

Browse files
committed
user: localization support for oauth registration ui
1 parent 04f38cd commit e2a53e8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

pointercrate-user-api/src/pages.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub async fn google_oauth_login(
157157
}
158158

159159
#[cfg(feature = "oauth2")]
160+
#[localized]
160161
#[rocket::post("/oauth/google/register", data = "<payload>")]
161162
pub async fn google_oauth_register(
162163
payload: Json<OauthRegistration>, key_store: &State<GoogleCertificateStore>, ip: IpAddr, pool: &State<PointercratePool>,

pointercrate-user-pages/src/register.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use maud::{html, Markup, PreEscaped};
2+
use pointercrate_core::localization::task_lang;
23
use pointercrate_core::{localization::tr, trp};
34
use pointercrate_core_pages::head::HeadLike;
45
use pointercrate_core_pages::PageFragment;
@@ -20,6 +21,8 @@ pub fn registration_page() -> PageFragment {
2021
}
2122

2223
fn register_page_body() -> Markup {
24+
let lang = task_lang().language.to_string();
25+
2326
html! {
2427
div.center #register style="display: flex; align-items: center; justify-content: center; height: calc(100% - 70px)" { // 70px = height of nav bar
2528
div.flex.col style="align-items: center" {
@@ -38,6 +41,7 @@ fn register_page_body() -> Markup {
3841
data-client_id=(config::google_client_id())
3942
data-callback="googleOauthRegisterCallback" {}
4043

44+
script src=(format!("https://accounts.google.com/gsi/client?hl={}", &lang)) async {}
4145
div .g_id_signin data-text="signup_with" style="margin: 10px 0px" {}
4246
@if cfg!(feature = "legacy_accounts") {
4347
p.or style="text-size: small; margin: 0px" { (tr("login.methods-separator")) }
@@ -90,16 +94,16 @@ fn oauth_registration_dialog() -> Markup {
9094
div.dialog #oauth-registration-pick-username style="width: 400px" {
9195
span.plus.cross.hover {}
9296
h2.underlined.pad {
93-
"Pick your username:"
97+
(tr("register-oauth"))
9498
}
9599
form.flex.col novalidate = "" {
96100
p.info-red.output {}
97101
span.form-input #oauth-username {
98-
label for = "username" {"Username:"}
102+
label for = "username" { (tr("auth-username")) }
99103
input type = "text" name = "username";
100104
p.error {}
101105
}
102-
input.button.blue.hover type = "submit" style = "margin: 15px auto 0px;" value="Sign Up!";
106+
input.button.blue.hover type = "submit" style = "margin: 15px auto 0px;" value=(tr("register-oauth.submit"));
103107
}
104108
}
105109
}

pointercrate-user-pages/static/ftl/en/user.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ register = Sign Up
4848
.redirect = Don't have a pointercrate account yet? { $redirect-link } for one!
4949
.redirect-link = Sign up
5050
51+
register-oauth = Pick your username:
52+
.submit = Sign up!
53+
5154
## Users tab
5255
users = Users
5356

0 commit comments

Comments
 (0)