Skip to content

Commit

Permalink
style: run format
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene authored and eric-intuitem committed Feb 12, 2024
1 parent af91eea commit df6d904
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 61 deletions.
35 changes: 16 additions & 19 deletions frontend/project.inlang/settings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"$schema": "https://inlang.com/schema/project-settings",
"sourceLanguageTag": "en",
"languageTags": [
"en",
"fr"
],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
],
"plugin.inlang.messageFormat": {
"pathPattern": "./messages/{languageTag}.json"
}
}
"$schema": "https://inlang.com/schema/project-settings",
"sourceLanguageTag": "en",
"languageTags": ["en", "fr"],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
],
"plugin.inlang.messageFormat": {
"pathPattern": "./messages/{languageTag}.json"
}
}
10 changes: 8 additions & 2 deletions frontend/src/lib/components/SideBar/SideBarFooter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@
class="unstyled cursor-pointer flex items-center gap-2 w-full px-4 py-2.5 text-left text-sm hover:bg-gray-100 disabled:text-gray-500 text-gray-800"
data-testid="profile-button"><i class="fa-solid fa-address-card mr-2" />My profile</a
>
<select {value} on:change={handleLocaleChange} class="border-y-white border-x-gray-100 focus:border-y-white focus:border-x-gray-100 w-full cursor-pointer block text-sm text-gray-800 bg-white focus:ring-0">
<select
{value}
on:change={handleLocaleChange}
class="border-y-white border-x-gray-100 focus:border-y-white focus:border-x-gray-100 w-full cursor-pointer block text-sm text-gray-800 bg-white focus:ring-0"
>
{#each availableLanguageTags as lang}
<option value={lang} selected={lang === languageTag()}>{LOCALE_MAP[lang].flag} {LOCALE_MAP[lang].name}</option>
<option value={lang} selected={lang === languageTag()}
>{LOCALE_MAP[lang].flag} {LOCALE_MAP[lang].name}</option
>
{/each}
</select>
<button
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/lib/utils/locales.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export const LOCALE_MAP = {
'en': {
'name': 'English',
'flag': '🇬🇧'
},
'fr': {
'name': 'French',
'flag': '🇫🇷'
},
}
en: {
name: 'English',
flag: '🇬🇧'
},
fr: {
name: 'French',
flag: '🇫🇷'
}
};
21 changes: 11 additions & 10 deletions frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Most of your app wide CSS should be put in this file
import '../app.postcss';
import ParaglideSvelte from './ParaglideJsProvider.svelte'
import ParaglideSvelte from './ParaglideJsProvider.svelte';
import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
Expand Down Expand Up @@ -63,13 +63,14 @@
deleteConfirmModal: { ref: DeleteConfirmModal }
};
</script>

<ParaglideJsProvider>
<Modal components={modalRegistry} />
<Toast />
<slot />

{#if $flash}
{@const bg = $flash.type == 'success' ? '#3D9970' : '#FF4136'}
<div style:background-color={bg} class="flash">{$flash.message}</div>
{/if}
</ParaglideJsProvider>
<Modal components={modalRegistry} />
<Toast />
<slot />

{#if $flash}
{@const bg = $flash.type == 'success' ? '#3D9970' : '#FF4136'}
<div style:background-color={bg} class="flash">{$flash.message}</div>
{/if}
</ParaglideJsProvider>
47 changes: 26 additions & 21 deletions frontend/src/routes/ParaglideJsProvider.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<script>
import { languageTag, onSetLanguageTag, setLanguageTag, sourceLanguageTag } from '$paraglide/runtime';
import { onDestroy, onMount } from 'svelte';
import { browser } from '$app/environment';
import {
languageTag,
onSetLanguageTag,
setLanguageTag,
sourceLanguageTag
} from '$paraglide/runtime';
import { onDestroy, onMount } from 'svelte';
import { browser } from '$app/environment';
onMount(() => {
const valueFromSession = sessionStorage.getItem('lang') || sourceLanguageTag;
// @ts-ignore
setLanguageTag(valueFromSession);
})
onMount(() => {
const valueFromSession = sessionStorage.getItem('lang') || sourceLanguageTag;
// @ts-ignore
setLanguageTag(valueFromSession);
});
onDestroy(() => {
if (browser) {
sessionStorage.removeItem('lang');
}
})
onDestroy(() => {
if (browser) {
sessionStorage.removeItem('lang');
}
});
// initialize the language tag
$: _languageTag = languageTag;
// initialize the language tag
$: _languageTag = languageTag;
onSetLanguageTag((newLanguageTag) => {
// @ts-ignore
_languageTag = newLanguageTag;
});
onSetLanguageTag((newLanguageTag) => {
// @ts-ignore
_languageTag = newLanguageTag;
});
</script>

{#key _languageTag}
<slot></slot>
{/key}
<slot />
{/key}

0 comments on commit df6d904

Please sign in to comment.