Skip to content

Commit

Permalink
Update docs & sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Nov 25, 2023
1 parent 3a2a9d3 commit dec98e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial-routing-rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -192,7 +192,7 @@ export const ChangeLocale = component$(() => {
<>
<h2>{t('app.changeLocale@@Change locale')}</h2>
{config.supportedLocales.map(value => (
<a key={value.lang} class={{ active: value.lang == locale.lang }} href={getPath(url, value.lang)}>
<a key={value.lang} class={{ active: value.lang == locale.lang }} href={getPath(pathname, value.lang)}>
{dn(value.lang, { type: 'language' })}
</a>
))}
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -127,7 +127,7 @@ export const ChangeLocale = component$(() => {
<>
<h2>{t('app.changeLocale@@Change locale')}</h2>
{config.supportedLocales.map(value => (
<a key={value.lang} class={{ active: value.lang == locale.lang }} href={getPath(url, value.lang)}>
<a key={value.lang} class={{ active: value.lang == locale.lang }} href={getPath(pathname, value.lang)}>
{dn(value.lang, { type: 'language' })}
</a>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/components/change-locale/change-locale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -25,7 +25,7 @@ export const ChangeLocale = component$(() => {
<h2>{t('app.changeLocale')}</h2>
<div class="names">
{config.supportedLocales.map(value => (
<a key={value.lang} class={{ button: true, active: value.lang == locale.lang }} href={getPath(url, value.lang)}>
<a key={value.lang} class={{ button: true, active: value.lang == locale.lang }} href={getPath(pathname, value.lang)}>
{dn(value.lang, { type: 'language' })}
</a>
))}
Expand Down

0 comments on commit dec98e1

Please sign in to comment.