-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add locale to headers devxapi (#500)
* add accept-language to queries to the devxApi * remove localisation from sample queries * add placeholder texts to localisation * reuse locale code to enable url overriding * add reference to new translation files * delete unused translation files * add try catch to sample queries fetch
- Loading branch information
Showing
16 changed files
with
53 additions
and
1,941 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
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,22 @@ | ||
const localeMap: any = { | ||
'de-de': 'de-DE', | ||
'en-us': 'en-US', | ||
'es-es': 'es-ES', | ||
'fr-fr': 'fr-FR', | ||
'ja-jp': 'ja-JP', | ||
'pt-br': 'pt-BR', | ||
'ru-ru': 'ru-RU', | ||
'zh-cn': 'zh-CN' | ||
}; | ||
|
||
function getTryItLocale() { | ||
return new URLSearchParams(location.search).get('locale'); | ||
} | ||
|
||
function getPortalLocale(): string { | ||
return location.pathname.split('/')[1].toLocaleLowerCase(); | ||
} | ||
|
||
const hostDocumentLocale = getTryItLocale() || getPortalLocale(); | ||
|
||
export const geLocale = hostDocumentLocale && localeMap[hostDocumentLocale] || 'en-US'; |
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
Oops, something went wrong.