From 4a30e71f7e847c731c31152c21b352b1caa433ce Mon Sep 17 00:00:00 2001 From: Nicolas Meseguer Date: Sun, 28 Apr 2024 01:34:14 +0200 Subject: [PATCH] Refactored the multi-language logic. --- README.md | 47 ++++++++++++++++++++++++----------- assets/img/en_flag.webp | Bin 11626 -> 0 bytes assets/img/es_flag.webp | Bin 5614 -> 0 bytes assets/js/languageManager.js | 43 ++++++++++++++++++++++++++++++++ assets/js/languages.json | 11 ++++++++ assets/js/main.js | 46 +++++----------------------------- index.html | 1 + 7 files changed, 93 insertions(+), 55 deletions(-) delete mode 100644 assets/img/en_flag.webp delete mode 100644 assets/img/es_flag.webp create mode 100644 assets/js/languageManager.js create mode 100644 assets/js/languages.json diff --git a/README.md b/README.md index 993bda9..3868382 100644 --- a/README.md +++ b/README.md @@ -7,33 +7,50 @@ Academic Portfolio ===================================== -You can find the LIVE Website [here](https://nicolasmeseguer.github.io). +HTML5 + CSS3 + JavaScript, responsive, and minimalistic template for academic portfolios (made from scratch, taking in consideration some details from Beautiful Jekyll templates). -This template has been made from scratch taking in consideration some details from Beautiful Jekyll templates. +You can find the LIVE Website [here](https://nicolasmeseguer.github.io). Reach me @ [n.mesegueriborra@um.es](mailto:n.mesegueriborra@um.es). -Language --------- -Add the class `language` to the code block to enable language translation. +How To Use This Template +===================================== -```html -
- - +1. Fork this repository [here](https://github.com/NicolasMeseguer/nicolasmeseguer.github.io/fork). +2. Go to the settings of your forked repository and rename it to `yourusername.github.io`. +3. Create a new branch called `gh-pages`. +4. Go to the settings of your repository and enable GitHub Pages. +5. Select the `gh-pages` branch as the source. +6. Consider giving this repository a star if you liked it ๐Ÿค. + + + +Multi-Language +-------- +ยฟWant to add multi-language support? It's easy! Just follow these steps: + +1. Add your language to the `assets/js/languages.json` file, according to ISO 3166 alpha-2 standard. For example, for english and spanish: +```json +"en": { + "flag": "https://flagcdn.com/w20/us.png" +}, +"es": { + "flag": "https://flagcdn.com/w20/es.png" +} ``` +2. Add the class `language` to each `` you would like to translate, and include the `data-` attribute with the translation. For example, for a greeting in english and spanish: ```html -
- - + + + ``` +3. Enjoy your multi-language portfolio! ๐ŸŒ + Contributing ------------ -Feel free to contribute to this project. You can do so by forking the project and submitting a pull request. You can find a list of issues/TODOs in the [issues tab](https://github.com/NicolasMeseguer/nicolasmeseguer.github.io/issues). - -Also, if you have any suggestions or feedback, please let me know by creating a new issue. +Feel free to contribute to this project. You can do so by forking the project and submitting a pull request. Find a list of issues/TODOs in the [issues tab](https://github.com/NicolasMeseguer/nicolasmeseguer.github.io/issues). Suggestions or feedback are well received. License ------- diff --git a/assets/img/en_flag.webp b/assets/img/en_flag.webp deleted file mode 100644 index 3637ce77342eaa00a7e4cfdcaadb3c30f720b09b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11626 zcmV-wEtS$zNk&FuEdT&lMM6+kP&iChEdT&7#{eM!>QKOz3%QZ?#D)Vj*Pqey1To(ySrX@ zTX*-}@pX51cblo(=lAbB({s)PAal7cDegpnoOr4xTvC^ms)Qt zBe-%R++kz%kA~J&CnMadD{D`HN3c;xq!gzLcTHUz+nDO$)TX$5dU*s?S2gkoR&dKG zQqsoVx@zi1STwbDkVp?2+MlX}yR6~vM6LswOXC{3g+v{Z^DkU8cejm*tf`umh&niA zMEe|Y*RCSk?Am-Ox9r9^A1re@XyopeaU)!|5f9k59gn1K+ja%T7-a=zTQgk<+O};Q zrFQpNH`=!C?v#yj+qT_R3xxpy2({Wjd-{yoc&%3JI)=O4W!uf(njeQ}dv=~}v-&T= zZ6rsMn0ww-tgFhJ$^C$x>;F${bN;vaJh$)1z8Q{f+xARsb8OqTZQHi-*kc>_+53P0 z&pH2dKW%K=<*eyq+o>|`lXB4A^A@IxYTG-;)5W$~W!bjvq)qqKv1_wp<@B~urB9vG zHoA1yE658-IvXcW?k;xqyoPDB#4Cj;cGI(W%Z<|)ZF6H@ZO7Kk+qP}nwr#b&ZJV>VYqo9n zAA%!ElA6rHTDR;yq3MO0c|d$vey!pQ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X<0@AoU{4n176X|3n@|44+V(GM^#K@W|KT?u_cjXBBkd@6!@R+HNrRVE>{!a_@{}5b zhPKptTG@Wa1X_TU{rLOyht}K3ockkSw>-%guC^~IsU->}G~ewvxi`Y#6o1?DgVY$@ ziyUl=dp_cD99wrL;bLw36}$cn40HVWyVavx?!ogs#fZy${MZ@DypR`@`|Y%^iM#XX oTy>yfNZqyT1OWlNWr@9T=^iUmIz%W}bdSlbnXCoQ3lj?G0(;%0i2wiq diff --git a/assets/img/es_flag.webp b/assets/img/es_flag.webp deleted file mode 100644 index 32901bb97e8ea6af63106edde13a3a7803c08993..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5614 zcmV?&W>wykNlZ5v};bGN(Ol)JmTySw{+*L!pNc~+4E6(A4@P7*W%K@tK4hq}9aZ#k{r zvQwb7?TjQnN&XlWm6A%eG1C~kv9@j7w(T9;?zL_2j@Pzr?^gdANs^Q(VO>u+9}p{6 zsYZC3|DFPuaG{QB1jsZ{jo|*!pc-L2Ks7=E@FcKM2v7<6Kryfsz^H=~V97DTMUpnb zsDsQ?`~(tLpi_Z&(CI6H$kD2ae57BzZW+L&7Xe65R#>G#Dab|Fe&I!F4RFigVEMNn zZ~Tv*Jb(=O!pnRKXk-9GazaDnaJfu&Igs_g)&=Ycg1z0|)-gZUx_}vm|Jc4ZJ)8Iy zS_s%sdux{qJ~V!DCoW9`1FuFz^nP@&gEG1|$e2aORri%$VN zr(6{^19{%2X5c5>a?~x}PK!AL z50v6_4g!Y&6J6flKm0K8$|dIze5kjNN?PvbBJ^wA#j#$+TS@s7-cp}%iT6aSL+6P3 z8FZ$t8<v?oOKrgCCj*hYR7{qhbN9-$uG0s^M@D-*S`$je-fR@0Q;erVtSLv?L1uE+lbfIvd zAkI|y$qINIE|*)H55~3*bqKn`PGn)c=%&`?KncV9-K4_~E;3<-VEQIUd+4}+&;>^W zk2k~lD-bDN=_(LVQ`Ay~P@Pn~3}mILBFbZ#iJ4%?8q;MQn}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GpF?6R0?s z4PeZg$C8+QrC}w2)vg0xiPhAxXbhwV4u`{HJSj9(Q;k49<^fTUd0EtBo}5^*N;SgM I{P&c%I3W%SoB#j- diff --git a/assets/js/languageManager.js b/assets/js/languageManager.js new file mode 100644 index 0000000..fc98804 --- /dev/null +++ b/assets/js/languageManager.js @@ -0,0 +1,43 @@ +class LanguageManager { + constructor() { + this.loadConfig(); + } + + async loadConfig() { + const response = await fetch("/assets/js/languages.json"); + this.config = await response.json(); + this.availableLanguages = Object.keys(this.config.languages); + this.setLanguage(localStorage.getItem("lan") || this.config.default); + } + + setLanguage(languageCode) { + if (!this.config.languages[languageCode]) { + console.warn(`Language code ${languageCode} not supported.`); + return; + } + + localStorage.setItem("lan", languageCode); + const languageData = this.config.languages[languageCode]; + + $("#lan img").attr("src", languageData.flag); + $("body").attr("class", languageCode); // Usa la clase en el body para manejar estilos CSS + + this.updateLanguage(); + } + + updateLanguage() { + const lang = localStorage.getItem("lan"); + $(".language *").each(function () { + const element = $(this); + const translation = element.data(lang); + element.html(translation); + }); + } + + getNextLanguage() { + const currentLang = localStorage.getItem('lan'); + let currentIndex = this.availableLanguages.indexOf(currentLang); + let nextIndex = (currentIndex + 1) % this.availableLanguages.length; + return this.availableLanguages[nextIndex]; + } +} diff --git a/assets/js/languages.json b/assets/js/languages.json new file mode 100644 index 0000000..a923926 --- /dev/null +++ b/assets/js/languages.json @@ -0,0 +1,11 @@ +{ + "default": "en", + "languages": { + "en": { + "flag": "https://flagcdn.com/w20/us.png" + }, + "es": { + "flag": "https://flagcdn.com/w20/es.png" + } + } +} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js index 38962c8..d6713f4 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -30,13 +30,8 @@ $(document).ready(function(){ localStorage.theme = "dark"; } - // First time, check the locale - let userLang = navigator.language || navigator.userLanguage; - if(localStorage.getItem("lan") === null){ - localStorage.lan = "en"; - if (userLang.split('-')[0] == "es") - localStorage.lan = "es"; - } + // Create the language manager + const langManager = new LanguageManager(); // Maybe first time or not, so load the localStorage value $('').appendTo('head').attr({ @@ -54,12 +49,6 @@ $(document).ready(function(){ }); $('#theme').empty().append(""); } - // Done because light is the one by default - if(localStorage.lan == "es") { - $('#lan img').attr("src","/assets/img/es_flag.webp"); - $('#lan').addClass("es"); - } - updateLanguage(); // Handle 'About Me' content $('#aboutme').click(function(e) { @@ -316,35 +305,12 @@ $(document).ready(function(){ } }) - // Animates the lan button + functionality - $('#lan').click(function(e) { - if(!$(e.currentTarget).hasClass('es')){ - $(e.currentTarget).addClass('es'); - - $('#lan img').attr("src","/assets/img/es_flag.webp"); - - localStorage.lan = "es" - } - else { - $(e.currentTarget).removeClass('es'); - - $('#lan img').attr("src","/assets/img/en_flag.webp"); - - localStorage.lan = "en" - } - - updateLanguage(); - }) - + $('#lan').click(function() { + const newLang = langManager.getNextLanguage(); + langManager.setLanguage(newLang); + }); }); -function updateLanguage() { - let lang = localStorage.lan; - $(".language *").each(function(){ - $(this).html( $(this).data(lang) ); - }); -} - function clearActiveLinks() { $('#navbarList .nav-item .nav-link').each(function() { $(this).removeClass('active'); diff --git a/index.html b/index.html index d0c0fc6..e873099 100644 --- a/index.html +++ b/index.html @@ -1018,6 +1018,7 @@

๐Ÿ“ž +