-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support locale / language / i18n (e.g. /[lang]/about
, /[lang]/features
), when SvelteKit has a standard approach for locales
#3
Comments
/[lang]/about
, /[lang]/features
)
/[lang]/about
, /[lang]/features
)/[lang]/about
, /[lang]/features
)
/[lang]/about
, /[lang]/features
)/[lang]/about
, /[lang]/features
)
/[lang]/about
, /[lang]/features
)/[lang]/about
, /[lang]/features
), when SvelteKit has a standard approach for locales
/[lang]/about
, /[lang]/features
), when SvelteKit has a standard approach for locales/[lang]/about
, /[lang]/features
), when SvelteKit has a standard approach for locales
Hi, Jason! Thanks for the good work. Is there an update for this issue? I'm thinking of using this library for my website (after doing the sitemap manually 😅). Right now https://inlang.com/m/gerre34r/library-inlang-paraglideJs seems to be the goto solution for i18n in SvelteKit since the inlang team is collaborating with the sveltekit maintainers. What are your thoughts? |
What I could do create a solution that is independent of the i18n system being used. For example, a config property for Super Sitemap that lets the dev specify their default lang and an array of alternate langs.
Does that seem reasonable? The Svelte maintainers help many devs, so I wouldn't consider Inlang to be the blessed SvelteKit i18n solution just yet. Imho, it's TBD what the best UX will be for an i18n solution in SvelteKit, given other cool solutions exist like https://lingui.dev/tutorials/cli, although not for SvelteKit yet. So I'd prefer to keep this agnostic to the i18n lib until there is an approach recommended by the SvelteKit docs or a defacto standard that is widely used. |
Will this expose an option to work with the optional parameters feature that Super Sitemaps already supports? e.g.: having a <urlset>
<url>
<loc>https://example.com/de</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
</url>
<url>
<loc>https://example.com/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
</url>
<url>
<loc>https://example.com/de/about</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/about" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
</url>
<url>
<loc>https://example.com/about</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/about" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about" />
</url>
</urlset> instead of <urlset>
<url>
<loc>https://example.com/de</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
</url>
<url>
<loc>https://example.com/en</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
</url>
<url>
<loc>https://example.com/de/about</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/about" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about" />
</url>
<url>
<loc>https://example.com/en/about</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/about" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/about" />
</url>
</urlset>
Sure! Is it feasible to have a special |
Yep, the existing
I think we have the same end goal in mind, where the default language exists at the shorter path (e.g. Question: On your site, do all of your routes exist within a directory that is an optional parameter, like |
Yes and no. All content routes do exist within a
P.S: This could already work (partially) for my use case but I'm still generating the sitemap manually because I need the alternate links. |
Okay. Thanks. I'm going to think on this a bit more, but have an idea how to approach it now. I can't get to this immediately, but probably later this month.
No worries there. Super Sitemap only includes routes containing a |
@buhodev i18n support is now included in v0.14.12 on NPM. Instructions are available in the README. Let me know if anything is unclear please. I misspoke earlier about I need to give it more thought--how to expose it in the config and docs for the best DX, etc. But wanted to get this out and available. |
@buhodev let me know if you get a chance to test this on your site, so I can be sure it's working for others too. I'm closing this thread as completed, and created a new issue for adding |
Hi, @jasongitmail! Sorry for the late response (I forgot to check this issue earlier) and thanks for the new feature! From a quick test, I'm facing an issue right now with the way I'm defining my dynamic route with matching. I'm following the example from the docs: import * as sitemap from 'super-sitemap';
import type { RequestHandler } from '@sveltejs/kit';
export const prerender = true; // optional
export const GET: RequestHandler = async () => {
return await sitemap.response({
origin: 'https://syself.com',
lang: {
default: 'en', // e.g. /about
alternates: ['de'] // e.g. /zh/about, /de/about
},
paramValues: {
// '/[[lang=lang]]': ['', 'de']
}
});
}; And I'm getting this error: Error: Sitemap: paramValues not provided for: '/[[lang=lang]]'
Update your sitemap's excludedPatterns to exclude this route OR add data for this route's param(s) to the paramValues object of your sitemap config. In the docs I saw that this dynamic route must be name If I uncomment this line: import * as sitemap from 'super-sitemap';
import type { RequestHandler } from '@sveltejs/kit';
export const prerender = true; // optional
export const GET: RequestHandler = async () => {
return await sitemap.response({
origin: 'https://syself.com',
lang: {
default: 'en', // e.g. /about
alternates: ['de'] // e.g. /zh/about, /de/about
},
paramValues: {
+ '/[[lang=lang]]': ['', 'de']
}
});
}; I get this error: Error: Sitemap: paramValues not provided for: '/[[lang=lang]]/about'
Update your sitemap's excludedPatterns to exclude this route OR add data for this route's param(s) to the paramValues object of your sitemap config. |
|
It worked flawlessly 😄 Thanks!
I see the problem. Right now I can't imagine what routes could go outside of the Another corner case would be Maybe an idea: return await sitemap.response({
paramValues: {
// 'lang_only' (super-sitemap prepends [[lang]] automatically)
// 'no_lang' (user needs to prepend any dynamic path in the keys)
// ...more options
$mode: 'lang_only',
'/blog/[post]': ['hello-world', 'another-post'],
}
}); |
Awesome 😄 hmm That's a new idea. I'll think on it a bit. Generally, I'm averse to adding options and prefer opinionated approach that simplifies/reduces what new devs are required to learn, to make it easiest to use. |
Punting on this until SvelteKit natively supports i18n.
Will need to read a list of locales supported by the app (e.g.
en
,es
), and a default locale (e.g.en
) for which we will not add a URL segment (e.g./features
,/es/features
).Then need to look into hreflang elements:
Supporting info
Related SvelteKit issues to follow
/hello
and/hola
instead of/hello
and/es/hello
, what to do if a translation is missing, etc)The text was updated successfully, but these errors were encountered: