I’m already finishing my portfolio and I want to have it in two languages: spanish and english. I already have all the texts for both languages and I’ve thought to copy all the pages from spanish and change the texts to english. Then, add all this pages into an english folder called /en.
Is this a good practice?
Another problem I have, is with the 404 error page. Since my website has two languages, I need two 404 error pages. One working for the regular URL which is in spanish (www.mywebsite.com/aksdaskd) and one working for the english version (www.mywebsite.com/en/aksdaskd). So my question is: How can I achieve this?
If someone is interested in the code I have used to achieve this, here it is:
<script>
var win = window.location;
var webPath = win.pathname;
//Add the var for each one of the language divs
var x = document.getElementById("404-spanish");
var y = document.getElementById("404-english");
//Divide the url in segments with the "/" character
var splittedPath = webPath.split("/");
//As the main link structure would be: jonathancenteno.com/en we need to select the first part of the url. In this case the parameter is 1.
switch(splittedPath[1]) {
//For the english language we display the english div and hide the spanish one
case "en":
x.style.display = "none";
y.style.display = "block";
break;
//Since the default version of my website is in spanish, I haven't added any more values. But, if you have more languages, you can add more values as the "en" one.
default:
y.style.display = "none";
break;
}
</script>