Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement of spanish version #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MrCoffe2k
Copy link

Spanish version

I implemented the spanish version of the webpage only by separating in diferents lenguajes the index and making an specific template.json.
Also adding a link to redirect to each site.

Copy link
Owner

@VojtaStruhar VojtaStruhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some things I'd like changed code-wise, to make the multi-language support more sustainable. We can then be ready for adding more languages, which is pretty exciting 🤩

Thanks for taking the time to do spanish! I love it 🇪🇸

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These vscode settings are personal preference. I'd rather it not be in the repo

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!

<PageLayout title="Plantilla de reseñas de steam">
<header class="bg-slate-700 text-white py-2 flex flex-col items-center">
<h1>{"---{ Plantilla para reseñas }---"}</h1>
<a href="/steam-review-template/en/" class="mt-0 text-white">Sitio en ingles</a>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this subtitle line, can we maybe do emojis in the corner? Something more subtle 🇪🇸 🇬🇧

Comment on lines +86 to +152
<script>
var data = {};
import config_json from "../../review_templates/template_en.json";

function showOutput() {
copyButton?.style.setProperty("display", "block");
let output = document.getElementById("output");
if (output) {
output.innerHTML = "";
config_json.categories.forEach((category) => {
output.innerHTML += `\n---{ ${category.title} }---\n`;
category.options.forEach((item) => {
if (
category.type === "check" &&
data[category.title].includes(item)
) {
output.innerHTML += `☑ ${item}\n`;
} else if (data[category.title] === item) {
output.innerHTML += `☑ ${item}\n`;
} else {
output.innerHTML += `☐ ${item}\n`;
}
});
});

output.innerHTML += `\n`;
output.innerHTML += `---{ Author }---\n`;
output.innerHTML += `☑ https://vojtastruhar.github.io/steam-review-template \n`;
}
}

let outputButton = document.getElementById("output-button");
if (outputButton) {
outputButton.addEventListener("click", showOutput);
}
let copyButton = document.getElementById("copy-output");
if (copyButton) {
copyButton.addEventListener("click", () => {
navigator.clipboard.writeText(
document.getElementById("output").innerText
);
});
}
copyButton?.style.setProperty("display", "none");

[...document.getElementsByTagName("input")].forEach((input) => {
if (input.type == "checkbox") {
data[input.name] = [];
}
input.addEventListener("change", (event) => {
let target = event.target;
if (target) {
if (target.type == "checkbox") {
if (target.checked) {
data[target.name].push(target.value);
} else {
data[target.name] = data[target.name].filter(
(item) => item != target.value
);
}
} else {
data[target.name] = target.value;
}
}
});
});
</script>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have more than 1 language, this can definitely be refactored. I'd say it's going to be a function in a separate .js file with a language argument? Can Astro do that?

</fieldset>
</form>
))
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't care about what language it is. We should refactor it into a separate file, so that adding more languages is easier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants