diff --git a/README.md b/README.md index 13ed945..e70a4ef 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,9 @@ Localize a path, an URL or an array of paths with the language - `translatePath: () => (route: (string | URL) | string[], lang?: string)` Translates a path, an URL or an array of paths. The translating string can be in any language. If not specified the target lang is the current one +- `validateLocale(lang: string)` +Validate `language[-script][-region]` + ### Testing - `QwikSpeakMockProvider` component provides the Speak context to test enviroments diff --git a/docs/tutorial-routing-rewrite.md b/docs/tutorial-routing-rewrite.md index 0576f30..2c75279 100644 --- a/docs/tutorial-routing-rewrite.md +++ b/docs/tutorial-routing-rewrite.md @@ -180,7 +180,7 @@ import { useSpeakLocale, useSpeakConfig, useDisplayName, inlineTranslate, transl export const ChangeLocale = component$(() => { const t = inlineTranslate(); - const url = useLocation().url; + const pathname = useLocation().url.pathname; const locale = useSpeakLocale(); const config = useSpeakConfig(); @@ -192,7 +192,7 @@ export const ChangeLocale = component$(() => { <>

{t('app.changeLocale@@Change locale')}

{config.supportedLocales.map(value => ( - + {dn(value.lang, { type: 'language' })} ))} diff --git a/docs/tutorial-routing.md b/docs/tutorial-routing.md index 857375c..70362a3 100644 --- a/docs/tutorial-routing.md +++ b/docs/tutorial-routing.md @@ -115,7 +115,7 @@ import { useSpeakLocale, useSpeakConfig, useDisplayName, inlineTranslate, locali export const ChangeLocale = component$(() => { const t = inlineTranslate(); - const url = useLocation().url; + const pathname = useLocation().url.pathname; const locale = useSpeakLocale(); const config = useSpeakConfig(); @@ -127,7 +127,7 @@ export const ChangeLocale = component$(() => { <>

{t('app.changeLocale@@Change locale')}

{config.supportedLocales.map(value => ( - + {dn(value.lang, { type: 'language' })} ))} diff --git a/src/components/change-locale/change-locale.tsx b/src/components/change-locale/change-locale.tsx index 34c0f69..4327f3f 100644 --- a/src/components/change-locale/change-locale.tsx +++ b/src/components/change-locale/change-locale.tsx @@ -10,7 +10,7 @@ export const ChangeLocale = component$(() => { const t = inlineTranslate(); - const url = useLocation().url; + const pathname = useLocation().url.pathname; const locale = useSpeakLocale(); const config = useSpeakConfig(); @@ -25,7 +25,7 @@ export const ChangeLocale = component$(() => {

{t('app.changeLocale')}

{config.supportedLocales.map(value => ( - + {dn(value.lang, { type: 'language' })} ))}