Skip to content

Commit 7644c96

Browse files
committed
fix(i18n): fix urls
1 parent 3175951 commit 7644c96

8 files changed

Lines changed: 21 additions & 136 deletions

File tree

blob.css

Lines changed: 0 additions & 97 deletions
This file was deleted.

index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ <h2 class="title">
354354
</li>
355355
<li class="card card-flex inverse">
356356
<div class="title i18nelement" data-i18n="ember-training"><a href="http://bmeurant.github.io/ember/training/">ember training</a></div>
357+
<div class="date">
358+
<div class="date-badge child-date">
359+
<i class="fa fa-calendar-check"></i>2015&nbsp;-&nbsp;2018
360+
</div>
361+
</div>
357362
<div class="content i18nelement" data-i18n="ember-training-desc">I wrote an in-depth introduction to ember. Can be followed as an autonomous tutorial but also to serve as a tool for training.</div>
358363
<div class="symbol"><i class="fa-solid fa-book"></i></div>
359364
</li>
@@ -369,6 +374,11 @@ <h2 class="title">
369374
</li>
370375
<li class="card card-flex inverse">
371376
<div class="title i18nelement" data-i18n="opensource">OpenSource contributions</div>
377+
<div class="date">
378+
<div class="date-badge child-date">
379+
<i class="fa fa-calendar-check"></i>2015&nbsp;-&nbsp;2018
380+
</div>
381+
</div>
372382
<div class="content i18nelement" data-i18n="opensource-desc">Modest OpenSource contributions on <a href="https://github.com/emberjs/ember.js/pull/13553">ember framework</a>, creation of an <a href="https://github.com/bmeurant/ember-array-contains-helper">ember addon</a>, etc.</a></div>
373383
<div class="symbol"><i class="fa-solid fa-code"></i></div>
374384
</li>

javascript/i18n.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
export {extractLocale, getLangFromLocale}
22

3-
import { locales, localeDefault } from './locales'
43
import { langs, langDefault } from './langs'
54

6-
function extractLocale(pathname) {
7-
const urlPaths = pathname.split('/');
5+
function extractLocale(location) {
6+
const localeArg = location.search.split("lang=") || langDefault;
7+
let locale = localeArg[1] || langDefault;
8+
locale = locale.split("-")[0];
89

9-
let locale;
10-
let urlWithoutLocale;
11-
// We remove the URL locale, for example `/de-DE/about` => `/about`
12-
const firstPath = urlPaths[1];
13-
if (locales.filter((locale) => locale !== localeDefault).includes(firstPath)) {
14-
locale = firstPath;
15-
urlWithoutLocale = '/' + urlPaths.slice(2).join('/');
16-
} else {
17-
locale = localeDefault;
18-
urlWithoutLocale = pathname;
19-
}
20-
21-
return { locale, urlWithoutLocale }
10+
return locale;
2211
}
2312

2413
function getLangFromLocale(locale) {

javascript/locales.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

main.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { extractLocale, getLangFromLocale } from './javascript/i18n.js'
33
import { langs } from './javascript/langs'
44
import { getYears } from './javascript/dates.js'
55

6-
const { urlWithoutLocale, locale } = extractLocale(document.location.pathname);
6+
const locale = extractLocale(document.location);
77

88
async function i18Loader(lang) {
99
const jsons = await Promise.all(
@@ -67,7 +67,7 @@ async function i18Loader(lang) {
6767
}
6868

6969
function updateUrl(lang) {
70-
window.history.pushState({}, "", `/${lang}`);
70+
window.history.pushState({}, "", `/?lang=${lang}`);
7171
}
7272

7373
const langSelectors = document.querySelectorAll('.langSelector');
@@ -97,21 +97,6 @@ function updateEmail() {
9797
document.getElementById("email").href = "mailto:baptiste.meurant@gmail.com";
9898
}
9999

100-
function showResponsiveMenu() {
101-
var menu = document.getElementById("menu");
102-
var icon = document.getElementById("hamburger-menu");
103-
var root = document.getElementById("header");
104-
if (menu.className === "") {
105-
menu.className = "open";
106-
icon.className = "open";
107-
root.style.overflowY = "hidden";
108-
} else {
109-
menu.className = "";
110-
icon.className = "";
111-
root.style.overflowY = "";
112-
}
113-
}
114-
115100
let lang=getLangFromLocale(locale);
116101

117102
i18Loader(lang);

public/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"projects": "Things I have done",
6060
"resthub": "Contributor, leader <a href=\"https://github.com/resthub\">RESTHub</a>",
6161
"resthub-desc": "Open source stack to build Modern Web Applications based on Spring, Backbone, Hibernate. Discontinued.",
62-
"ember-training": "Ember Training",
62+
"ember-training": "<a href=\"https://bmeurant.github.io/ember-training\">Ember Training</a>",
6363
"ember-training-desc": "An in-depth introduction to ember. Can be followed as an autonomous tutorial but also to serve as a tool for training.",
6464
"cnrs": "CNRS, <a href=\"https://aramis.resinfo.org/doku.php?id=ateliers:ecosystemjs-23032017\">JavaScript ecosystem presentation</a>",
6565
"cnrs-desc": "A 2-hour <a href=\"https://bmeurant.github.io/jsecosystem/#/\">presentation</a> on the JavaScript ecosystem for the CNRS ARAMIS network in Lyon.",

public/translations/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"projects": "Réalisations et projets",
6060
"resthub": "Contributeur, leader <a href=\"https://github.com/resthub\">RESTHub</a>",
6161
"resthub-desc": "Une stack OpenSource pour construire des applications Web modernes avec Spring, Backbone, Hibernate. Le projet est abandonné.",
62-
"ember-training": "Formation Ember",
62+
"ember-training": "<a href=\"https://bmeurant.github.io/ember-training\">Formation Ember</a>",
6363
"ember-training-desc": "Une introduction approfondie à ember. Peut être suivi comme un tutoriel autonome mais aussi servir d'outil de formation.",
6464
"cnrs": "CNRS, <a href=\"https://aramis.resinfo.org/doku.php?id=ateliers:ecosystemjs-23032017\">presentation de l'écosystème JavaScript</a>",
6565
"cnrs-desc": "Un <a href=\"https://bmeurant.github.io/jsecosystem/#/\">atelier</a> de 2 heures sur l'écosystème JavaScript pour le réseau ARAMIS du CNRS à Lyon.",

styles/resume.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ $smooth-emphasize-color: #a9d5d6;
3333
background-position-y: top;
3434

3535
&[name='fr'] {
36-
background-image: url("images/flag-fr.svg");
36+
background-image: url("/images/flag-fr.svg");
3737
}
3838

3939
&[name='en'] {
40-
background-image: url("images/flag-en.svg");
40+
background-image: url("/images/flag-en.svg");
4141
}
4242
}
4343

0 commit comments

Comments
 (0)