starlight-blog icon indicating copy to clipboard operation
starlight-blog copied to clipboard

i18n integration

Open BuckyBuck135 opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

Summary: Currently, the /blog route generated by the plugin doesn't seem to be supporting an i18n project. In my project, I have a root locale (fr), and another locale (en) in its own folder, as seen below.

.
├── src/
│   ├── assets/
│   ├── content/
│   │   ├── docs/
│   │   │   ├── en/
│   │   │   │   ├── blog/
│   │   │   │   │   └── first-article.md
│   │   │   │   │   └── second-article.md
│   │   │   │   └── about.mdx
│   │   │   │   └── index.mdx
│   │   │   ├── blog/
│   │   │   │   └── premier-article.md
│   │   │   │   └── deuxieme-article.md
│   │   │   └── a-propos.mdx
│   │   │   └── index.mdx
│   │   └── config.ts
│   └── env.d.ts
├── astro.config.mjs

However, when I try to set up a blog for the other locale (under docs/en/blog) I run into problems.

  • on the home page, I navigate to /blog, then hit the language switch => /en/blog returns 404
  • on the home page, I hit the language switch to get to /en, then navigate to blog => falls back to French /blog/

Describe the solution you'd like

The plug-in should accommodate an i18n setup. Creating a /blog folder in the different locales folders should generate a blog homepage and link accessible via /locale/blog/

Describe alternatives you've considered

No response

Additional Context

As the plug-in documentation doesn't refer to i18n, I still tried to set up a blog for the other locale (under docs/en/blog), but ran into problems described above.

Thank you for your time.

BuckyBuck135 avatar Apr 29 '24 09:04 BuckyBuck135

Thanks for your report :raised_hands:

i18n support is still something on my todo list at the moment. A complete and working solution is not yet something doable without additional improvements in Starlight itself, mostly this proposal.

I guess the 2 choices at hand are:

  • Implement a custom solution right now to at least generate the /blog, /blog/X, /blog/tags/Y pages in various languages by duplicating some Starlight code and having all UI strings in English in all languages.
  • Wait for some progress on the i18n front in Starlight and then implement a proper solution.

Considering I'm planning to start working on some parts of the linked proposal this week, I think I'll wait a bit before making a decision and get a better overview of the situation/timeline.

HiDeoo avatar Apr 29 '24 14:04 HiDeoo

Considering I'm planning to start working on some parts of the linked proposal this week, I think I'll wait a bit before making a decision and get a better overview of the situation/timeline.

Thank you HiDeoo, Reading that proposal you linked and realizing this is well above my skill level, there's no much I can do to help, except for French translation when the time comes! Looking forward to seeing how it goes.

BuckyBuck135 avatar Apr 29 '24 15:04 BuckyBuck135

Hello everyone,

I'm just wondering on the status of this as I'm currently working on website in English & Arabic.

My question is regarding which approach is best to take:

  1. Extending the starlight-blog by a) forking and making changes directly b) using components overriding? ( Don't how feasible this is)
  2. Creating separate files for Arabic?
  3. Hybrid approach, using plugin for English, custom implementation for Arabic? (That's what I'm currently doing)

The Hybrid approach is working well for me for handling the URLs and prefix. Check the screen shot.

However it feels like I'm repeating myself a bit and would personally prefer not having to create separate pages and components. Instead I'd prefer to use the ones for the plugin directly after modifying them to handle both routes for blog/ar and blog/.

Would really appreciate your thoughts on this.

Screenshot_20241008_105339

waleedsadek-panx avatar Oct 08 '24 08:10 waleedsadek-panx

To give a small update: one of the last changes required to properly support i18n at the plugin level both in terms of navigation/links and also UI strings has landed in Starlight 0.28.3 which was released a few hours ago.

I'll start working on implementing i18n support in this plugin in the next few days.

HiDeoo avatar Oct 08 '24 08:10 HiDeoo

That's great news! I spent the last few days figuring out what's the best way to implement that and wasn't too sure if creating a src/pages/[lang]/blog, authors, tags.astro and some custom components mirroring the plugin, is the best way to go.

Looking forward to it and let me know how I can help with that.

waleedsadek-panx avatar Oct 08 '24 08:10 waleedsadek-panx

To give a small update: one of the last changes required to properly support i18n at the plugin level both in terms of navigation/links and also UI strings has landed in Starlight 0.28.3 which was released a few hours ago.

I'll start working on implementing i18n support in this plugin in the next few days.

Cannot wait for it, I'm looking forward to i18n support as well.

cuongthachHQ avatar Oct 08 '24 10:10 cuongthachHQ

Thanks for your patience everyone :raised_hands:

It took a while to get all the pieces together to provide the i18n support I had in mind but it's finally available! Not saying this would be bug-free considering the size and potential complexity of the feature but now we should be able to easily iterate on it.

HiDeoo avatar Oct 16 '24 12:10 HiDeoo

Looking at page.ts blows my mind away. Congrats, and thanks Hideoo!

BuckyBuck135 avatar Oct 16 '24 12:10 BuckyBuck135