mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
docs(site): i18n handler, prettier code blocks and highlighting (#951)
* fix: sirv, commonjs plugin, add rollup sig * replace deprecated rollup plugins * remove dollarsign * fix i18n setting, code snippet styling, lng switch * fix segment, rm unused styles
This commit is contained in:
parent
8dbf0cfee0
commit
b5a7263124
@ -15,6 +15,8 @@ This flow has great support with most modern languages and frameworks and is the
|
|||||||
|
|
||||||
#### Typescript Authentication Example
|
#### Typescript Authentication Example
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
If you use a framework like Angular, Vue, React, ... you can use this code snippet here to integrate **ZITADEL** into you application
|
If you use a framework like Angular, Vue, React, ... you can use this code snippet here to integrate **ZITADEL** into you application
|
||||||
|
|
||||||
Library used for this example [https://github.com/IdentityModel/oidc-client-js](https://github.com/IdentityModel/oidc-client-js)
|
Library used for this example [https://github.com/IdentityModel/oidc-client-js](https://github.com/IdentityModel/oidc-client-js)
|
||||||
@ -60,3 +62,5 @@ export default class AuthService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
import { setCookie } from '../modules/cookie.js';
|
|
||||||
import { goto } from '@sapper/app';
|
import { goto } from '@sapper/app';
|
||||||
import { docLanguages } from '../modules/language-store.js'
|
import { docLanguages } from '../modules/language-store.js'
|
||||||
import {LANGUAGES} from '../../config.js';
|
import {LANGUAGES} from '../../config.js';
|
||||||
@ -40,7 +39,6 @@
|
|||||||
height: var(--height);
|
height: var(--height);
|
||||||
margin: .5rem 1rem;
|
margin: .5rem 1rem;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: white;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -49,12 +47,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
button.current {
|
button.current {
|
||||||
color: var(--prime);
|
color: var(--grey-text);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="language-switcher">
|
<div class="language-switcher">
|
||||||
{#each LANGUAGES as lang}
|
{#each LANGUAGES as lang}
|
||||||
<button on:click="{() => reload(lang)}" class="{lang == group ? 'current': ''}">{lang == 'de'? 'Deutsch' : 'English'}</button>
|
<button on:click="{() => reload(lang)}" disabled="{lang == group}" class="{lang == group ? 'current': ''}">{lang == 'de'? 'Deutsch' : 'English'}</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getLocaleFromNavigator, init, locale as $locale, register } from 'svelte-i18n';
|
import { getLocaleFromNavigator, init, locale as $locale, register } from 'svelte-i18n';
|
||||||
|
|
||||||
|
import { LANGUAGES } from '../config.js';
|
||||||
import { getCookie, setCookie } from './modules/cookie.js';
|
import { getCookie, setCookie } from './modules/cookie.js';
|
||||||
|
|
||||||
export const INIT_OPTIONS = {
|
export const INIT_OPTIONS = {
|
||||||
@ -8,6 +9,7 @@ export const INIT_OPTIONS = {
|
|||||||
loadingDelay: 200,
|
loadingDelay: 200,
|
||||||
formats: {},
|
formats: {},
|
||||||
warnOnMissingMessages: true,
|
warnOnMissingMessages: true,
|
||||||
|
localeOptions: LANGUAGES,
|
||||||
};
|
};
|
||||||
|
|
||||||
let currentLocale = null;
|
let currentLocale = null;
|
||||||
@ -28,9 +30,10 @@ $locale.subscribe((value) => {
|
|||||||
|
|
||||||
// initialize the i18n library in client
|
// initialize the i18n library in client
|
||||||
export function startClient() {
|
export function startClient() {
|
||||||
|
console.log('nav', getLocaleFromNavigator());
|
||||||
init({
|
init({
|
||||||
...INIT_OPTIONS,
|
...INIT_OPTIONS,
|
||||||
initialLocale: getCookie('locale') || getLocaleFromNavigator(),
|
initialLocale: getCookie('locale') || INIT_OPTIONS.localeOptions.find(option => option == cropCountryCode(getLocaleFromNavigator())) || INIT_OPTIONS.initialLocale,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +56,13 @@ export function i18nMiddleware() {
|
|||||||
// no cookie, let's get the first accepted language
|
// no cookie, let's get the first accepted language
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
if (req.headers['accept-language']) {
|
if (req.headers['accept-language']) {
|
||||||
const headerLang = req.headers['accept-language'].split(',')[0].trim();
|
const headerLngs = req.headers['accept-language'].split(',');
|
||||||
if (headerLang.length > 1) {
|
const headerLngCodes = headerLngs.map(lng => lng.split(';')[0].trim());
|
||||||
|
const headerLang = headerLngCodes.find(code => {
|
||||||
|
return INIT_OPTIONS.localeOptions.find(option => option == code);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (headerLang) {
|
||||||
locale = headerLang;
|
locale = headerLang;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -68,4 +76,8 @@ export function i18nMiddleware() {
|
|||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function cropCountryCode(code) {
|
||||||
|
return code.split('-')[0].trim();
|
||||||
}
|
}
|
@ -7,7 +7,6 @@
|
|||||||
import PhotoSwipe from '../components/PhotoSwipe.svelte';
|
import PhotoSwipe from '../components/PhotoSwipe.svelte';
|
||||||
const { page } = stores();
|
const { page } = stores();
|
||||||
export let segment;
|
export let segment;
|
||||||
console.log('seg:'+segment);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script context="module">
|
<script context="module">
|
||||||
@ -26,8 +25,6 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- <Nav {segment} title="{manifest.name}" logo="logos/zitadel-logo-light.svg"></Nav> -->
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<slot />
|
<slot />
|
||||||
<PhotoSwipe/>
|
<PhotoSwipe/>
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
locale.set(language);
|
locale.set(language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locale.subscribe(l => {
|
||||||
|
console.log(l);
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -206,7 +210,8 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>{$_('languagealsoavailable')}:
|
|
||||||
|
<p>{$_('languagealsoavailable')}:
|
||||||
{#each LANGUAGES as lang}
|
{#each LANGUAGES as lang}
|
||||||
{#if lang != $locale}
|
{#if lang != $locale}
|
||||||
<a href="/" on:click="{() => reload(lang)}" class="{lang == $locale ? 'current': ''}">{lang == 'de'? 'Deutsch (WIP)' : 'English'}</a>
|
<a href="/" on:click="{() => reload(lang)}" class="{lang == $locale ? 'current': ''}">{lang == 'de'? 'Deutsch (WIP)' : 'English'}</a>
|
||||||
|
@ -37,19 +37,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hljs-tag {
|
.hljs-tag {
|
||||||
color: #3dc9b0;
|
color: #f8b886;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-keyword {
|
.hljs-keyword {
|
||||||
color: #ff5370;
|
color: #ff2069;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-attr {
|
.hljs-attr {
|
||||||
color: #666;
|
color: #a3acb9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-number {
|
.hljs-number {
|
||||||
color: #3dc9b0;
|
color: #f8b886;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-type,
|
.hljs-type,
|
||||||
@ -59,16 +59,16 @@
|
|||||||
.hljs-quote,
|
.hljs-quote,
|
||||||
.hljs-template-tag,
|
.hljs-template-tag,
|
||||||
.hljs-deletion {
|
.hljs-deletion {
|
||||||
color: #298372;
|
color: #1ea672;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-title,
|
.hljs-title,
|
||||||
.hljs-section {
|
.hljs-section {
|
||||||
color: #298372;
|
color: #1ea672;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-literal {
|
.hljs-literal {
|
||||||
color: #3dc9b0;
|
color: #f8b886;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hljs-meta {
|
.hljs-meta {
|
||||||
|
@ -184,7 +184,7 @@ strong {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tt,
|
tt,
|
||||||
code,
|
/* code, */
|
||||||
kbd,
|
kbd,
|
||||||
samp {
|
samp {
|
||||||
font: 400 var(--code-fs)/1.7 var(--font-mono);
|
font: 400 var(--code-fs)/1.7 var(--font-mono);
|
||||||
@ -195,7 +195,8 @@ code {
|
|||||||
border-radius: .3em;
|
border-radius: .3em;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
-webkit-font-smoothing: initial;
|
-webkit-font-smoothing: initial;
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre code {
|
pre code {
|
||||||
|
@ -3,7 +3,7 @@ code[class*="language-"] {
|
|||||||
color: #d4d4d4;
|
color: #d4d4d4;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
@ -36,7 +36,7 @@ pre[class*="language-"] {
|
|||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: .5em 0;
|
margin: .5em 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background: #3c4257;
|
background: #2A2F45;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user