HiDeoo / starlight-blog

Starlight plugin to add a blog to your documentation
https://starlight-blog-docs.vercel.app
MIT License
159 stars 21 forks source link

Language support #9

Closed Ranily57 closed 8 months ago

Ranily57 commented 1 year ago

Is your feature request related to a problem?

It's not a real problem, just it's not the best idea to modify the source code on the node_module to change the language.

Describe the solution you'd like

I think about a way to get the language selected on the astro config and use it for the default text on the blog compoment.

Describe alternatives you've considered

Creating a compoment to select the language of the blog, but it's not very optimized to have 2 language system

Additional Context

Example of what i write:

const blogSidebar = isBlog
  ? [
      {
        href: '/blog',
        isCurrent: isBlogRoot(Astro),
        label: 'All posts',
        type: 'link',
      },
      {
        entries: recentEntries.map((blogEntry) => ({
          href: `/${blogEntry.slug}`,
          isCurrent: isBlogPostPage(Astro, blogEntry.slug),
          label: blogEntry.data.title,
          type: 'link',
        })),
        label: 'Recent posts',
        type: 'group',
      },
    ]
  : []

with translation:

const blogSidebar = isBlog
  ? [
      {
        href: '/blog',
        isCurrent: isBlogRoot(Astro),
        label: translation.labelRoot,
        type: 'link',
      },
      {
        entries: recentEntries.map((blogEntry) => ({
          href: `/${blogEntry.slug}`,
          isCurrent: isBlogPostPage(Astro, blogEntry.slug),
          label: blogEntry.data.title,
          type: 'link',
        })),
        label: translation.labelRecent,
        type: 'group',
      },
    ]
  : []

And you can have a file like en.json :

{ 
"labelRoot": "All post",
"labelRecent": "Recent post"
}
HiDeoo commented 1 year ago

Thanks for the feedback.

I18n support is something that is in my todo list but it's great to have an issue to track it.

My current plan for i18n is to wait for several ongoing efforts with Starlight to be completed:

When these are done, the goal would be to transform this integration into an Starlight plugin (basically an integration that can update the Starlight configuration) so it could:

HiDeoo commented 8 months ago

Update: related Starlight proposal.