-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ffd000
commit d1e07d6
Showing
80 changed files
with
1,012 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/api-client": minor | ||
--- | ||
|
||
Add redirectUrl to the contextService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/helpers-next": minor | ||
--- | ||
|
||
Add internatiolization helpers with mocks data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"vue-demo-store": minor | ||
--- | ||
|
||
Add language switcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/composables-next": minor | ||
--- | ||
|
||
useInternationalization add methods related to the language switcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shopware-pwa/cms-base": minor | ||
--- | ||
|
||
Add language prefix to the links built on the CMS components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
head: | ||
- - meta | ||
- name: og:title | ||
content: "Work with languages" | ||
- - meta | ||
- name: og:description | ||
content: "How to build multi languages site" | ||
- - meta | ||
- name: og:image | ||
content: "https://frontends-og-image.vercel.app/Work%20with%20**languages**.png?fontSize=150px" | ||
--- | ||
|
||
# Work with languages | ||
|
||
:::warning | ||
This is the implementation working with `vue-demo-store` template only. To see the details, please go to the `templates/vue-demo-store` directory in the repository. | ||
::: | ||
Each store has two sources of translations. | ||
|
||
Backend source for: | ||
|
||
- CMS translations | ||
- Product and categories | ||
- Routing paths | ||
|
||
Frontend source for: | ||
|
||
- All static content declared on the frontend app | ||
|
||
## Configuration | ||
|
||
More about backend translations can be found [here](https://docs.shopware.com/en/shopware-6-en/tutorials-and-faq/translations) | ||
|
||
For the frontend app we recommend to use `vue-i18n` module. | ||
|
||
**_When you are using same domain:_** | ||
|
||
:::warning | ||
Backend languages codes and frontend languages codes must be the same! | ||
::: | ||
|
||
``` | ||
www.example.com // GB site | ||
www.example.com/de-DE // DE site | ||
``` | ||
|
||
``` | ||
{ | ||
i18n: { | ||
vueI18n: { | ||
fallbackLocale: "en-GB", | ||
}, | ||
strategy: "prefix_except_default", | ||
defaultLocale: "en-GB", | ||
langDir: "i18n/src/", | ||
locales: [ | ||
{ | ||
code: "en-GB", | ||
iso: "en-GB", | ||
file: "en-GB.ts", | ||
}, | ||
{ | ||
code: "de-DE", | ||
iso: "de-DE", | ||
file: "de-DE.ts", | ||
}, | ||
], | ||
}, | ||
} | ||
``` | ||
|
||
**_When you are using different domains:_** | ||
|
||
``` | ||
www.example1.com // GB site | ||
www.example2.com // DE site | ||
``` | ||
|
||
``` | ||
{ | ||
i18n: { | ||
vueI18n: { | ||
fallbackLocale: "en-GB", | ||
}, | ||
langDir: "i18n/src/", | ||
locales: [ | ||
{ | ||
domain: 'example1.com' | ||
code: "en-GB", | ||
iso: "en-GB", | ||
file: "en-GB.ts", | ||
}, | ||
{ | ||
domain: 'example2.com' | ||
code: "de-DE", | ||
iso: "de-DE", | ||
file: "de-DE.ts", | ||
}, | ||
], | ||
}, | ||
} | ||
``` | ||
|
||
## Routing | ||
|
||
When you are using _prefix_ domain languages, you have to use `useLocalePath()` composable for building URLs. | ||
The main task of this composable is to add a prefix to URL if needed. | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
const localePath = useLocalePath(); | ||
</script> | ||
<template> | ||
<NuxtLink :to="localePath('/account')"> Account</NuxtLink> | ||
</template> | ||
``` | ||
|
||
## Testing | ||
|
||
If you want to test languages locally, and your local domain differs from what is declared on the backend, you can use environment variables. | ||
|
||
``` | ||
NUXT_PUBLIC_SHOPWARE_DEV_STOREFRONT_URL=http://127.0.0.1:3000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function buildUrlPrefix(url: string | any, prefix: string) { | ||
if (typeof url === "string") { | ||
return prefix ? `/${prefix}${url}` : url; | ||
} | ||
if (url.path && prefix) { | ||
url.path = `/${prefix}${url.path}`; | ||
} | ||
|
||
return url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function getUrlPrefix() { | ||
try { | ||
return inject("urlPrefix", ""); | ||
} catch ($error) { | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.
d1e07d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shopware-frontends-docs – ./
shopware-frontends-docs-git-main-shopware-frontends.vercel.app
shopware-frontends-docs.vercel.app
shopware-frontends-docs-shopware-frontends.vercel.app
frontends.shopware.com
d1e07d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
frontends-demo – ./templates/vue-demo-store
frontends-demo.vercel.app
frontends-demo-git-main-shopware-frontends.vercel.app
frontends-demo-shopware-frontends.vercel.app