That would be ideal since having to mess with Astro and company just acts as a roadblock for non web devs.
glad you like the idea, with a quick search I found i18next JSON files - Weblate 5.5.4 documentation and GitHub - yassinedoghri/astro-i18next: An astro integration of i18next + some utility components to help you translate your astro websites!, I’m currently hacking on Community tracking but once I have finished I’ll look into getting this up
Amazing stuff, great to start somewhere. Just left my two cents. Though, I’m not the best for any kind of Astro review.
Please add me as a reviewer when you’re ready, I can do Astro review
I can handle the review. Am also well versed in Astro. And also yea for some reason you don’t have perms to add a reviewer. We’ll have to take a look at that.
Astro is quite comfy
A few hours ago I managed to create an incomplete Spanish version of the site but I ran into problems with my git setup. I can still provide the translations if someone can implement them.
Also, I think it would be a good idea to get them reviewed by another Spanish speaking person here such as @eri (if they are okey tho, I pinged them because I know they speak Spanish).
translations have moved into public/translations/{lang}/translations.json in my PR, it should be far easier to add new translations that way
I would love to review your translations and provide any suggestion or implement them in the website!
I’d be happy to review your translations, please feel free to request my review when your ready
Thanks to @marshmallow we now have support for multiple languages. We have merged their PR. So translators feel free to get started on the translation efforts.
I have a local dev session going, with the site displaying on http://localhost:4321, but I am unsure how I view the site in a specific language.
From the code I’ve read it should be by their identify for example http://localhost:4321/en/
for English.
That’s what I’ve been trying based on this: feat: i18n by mrshmllow · Pull Request #3 · auxolotl/website · GitHub, but given that I keep getting 404’s I’m guessing some type of redirect is missing - perhaps specifically from the dev mode?
taking a look into how i18n works for astro. Gimme a few moments.
Ok, I’ve done some digging @AngryAnt, there’s a couple of steps.
- In
src/pages
create a directory named the 2 letter code of the language (eg: french would befr
). - Copy and paste the index.astro file into the directory (it can stay unmodified).
- In
public/locales
create a directory named the same 2 letter code as earlier. - Copy
public/locales/en/translations.json
into the directory you just made. - Add the language in
src/i18n/ui.ts
in the same way English is added. - Do your translations.
There may be a way to do this with dynamic routing, but since Astro needs to build everything to static I’ll have to do some more research on that. This way is fine for now.
Excellent! I have it working. Notes for others:
- Remember to prefix all the imports in
index.astro
now that you have copied the file up one level. - Modified
ui.ts
looks something like this:
import en from "../../public/locales/en/translations.json"
import dk from "../../public/locales/dk/translations.json"
export const languages = {
en: 'English',
dk: 'Danish'
};
export const defaultLang = 'en';
export const ui = {
en,
dk
} as const;
I take it that for the PR I’ll not commit the duplicate index.astro
?