Skip to content

Commit

Permalink
feat: localize jwt.io banner japanese
Browse files Browse the repository at this point in the history
  • Loading branch information
byron-okta committed Jan 16, 2025
1 parent 5d0061e commit 17d2d40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
27 changes: 23 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,41 @@ if (process.env.NODE_ENV === "production") {
);
}

app.use((req, res, next) => {
const acceptLanguage = req.headers['accept-language'];

if(acceptLanguage){
const preferredLanguage = acceptLanguage.split(",")[0].split("-")[0];

req.preferredLanguage = preferredLanguage;
}else{
req.preferredLanguage = 'en';
}

next();
})

app.use((req, res, next) => {
res.locals.COOKIE_CONSENT_DOMAIN_ID = process.env.COOKIE_CONSENT_DOMAIN_ID;
next();
});
app.use(express.static("dist/website"));
app.get("/", function(req, res) {
res.render("index");
res.render("index", {
preferredLanguage: req.preferredLanguage,
});
});

app.get("/introduction", function(req, res) {
res.render("introduction");
res.render("introduction", {
preferredLanguage: req.preferredLanguage,
});
});

app.get("/libraries", function(req, res) {
res.render("libraries", {
languages: languages
languages: languages,
preferredLanguage: req.preferredLanguage,
});
});

Expand All @@ -44,4 +63,4 @@ app.get("/home", function(req, res) {

app.listen(process.env.PORT || 3000, function() {
console.log("Started.");
});
});
8 changes: 6 additions & 2 deletions views/website/navigation.pug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.top-banner-bg.closed
.top-banner.closed
.top-banner-container
a(href="https://a0.to/jwt-io-feedback" target="_blank") Get an exclusive look at jwt.io v2 and help us shape its final form with your feedback.
span(aria-hiden="true")
if preferredLanguage === 'ja'
a(href="https://a0.to/jwt-io-feedback-ja" target="_blank") jwt.io v2ベータバージョン: フィードバックをお寄せください。
span(aria-hiden="true")
else
a(href="https://a0.to/jwt-io-feedback" target="_blank") Get an exclusive look at jwt.io v2 and help us shape its final form with your feedback.
span(aria-hiden="true")
button.close-top-banner +

nav.navbar
Expand Down

0 comments on commit 17d2d40

Please sign in to comment.