how to add the lang folder to the baseLanguage.
See original GitHub issueHi, my current page structure is like this:
[lang]
- about.astro
- news.astro
- contact.astro
- index.astro
index.astro (homepage default lang or redirect to user locale)
So except for the homepage in baseLanguage I always add the [lang] to every URL. How can I do this?
(in my setup the HeadHrefLangs & LanguageSelector won’t work.)
I would like not to have a structure like this:
[lang]
- about.astro
- news.astro
- contact.astro
- index.astro
about.astro
news.astro
contact.astro
index.astro
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Add a new folder for base language - WPML
Hello,. You can enable to "Use directory for default language" from within WPML->Languages ->Language URL Format. When I visit the site I can ......
Read more >Language Configuration - HPL3 - Frictional Games Wiki
When configuring a language for a mod, you need to have two separate files: a base language file, and a main language file....
Read more >Introduction to Localization (add additional language support ...
Right click your project folder, select 'New File' , then scroll down to find 'Strings', select it and click 'Next'. Then name the...
Read more >How to set Base Localization & Development Language in ...
In the new Choose files and reference language to create German ... B. Use the default language as "Base" language: Untick "German" for ......
Read more >Maximo Language Files and Tables - Demystified - IBM
The Base Language is recorded in the MAXVARS table. ... The xliff files are stored in separate directory structures based on the 2...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s the catch when trying to have a dynamic route for languages! So, first, the easiest thing to do is to discard using getStaticPaths to declare localized routes.
Instead,
astro-i18next generate
would generate each declared locale in its own folder. For example, let’s say we have 3 languages (fr, es, en), english being the default language:astro-i18next generate
would generate the following at build time:And would add the following lines to the pages’ frontmatter so as not to touch to the
getStaticPaths
logic:I think that in terms of DX, this is the best. Apart from having to replace the text with translation keys, you wouldn’t have to do anything else.
And eventually, this also unlocks some other cool features, like what if we’d like to translate the routes?
astro-i18next generate
could also replace the file names for each language.Anyways, haven’t worked out the details yet, hopefully I can get something working this weekend 🤞
Hey, thanks for reporting the issue!
This is a concern I’ve had since the beginning and haven’t figured out a way to automate it yet!
I’ve thought about generating the language files during build time but there are some limitations with Astro’s integration API. I’ll have to take some time in finding my way around them.
I’ll try working on it this weekend and post my progress here 🙂