@everymatrix/general-logout 0.0.211 → 0.0.215

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.html CHANGED
@@ -30,8 +30,8 @@
30
30
  </header>
31
31
 
32
32
  <div class="webcomponent">
33
- <general-logout></general-logout>
33
+ <general-logout lang="en"></general-logout>
34
34
  </div>
35
-
35
+
36
36
  </body>
37
37
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/general-logout",
3
- "version": "0.0.211",
3
+ "version": "0.0.215",
4
4
  "main": "dist/general-logout.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "eb7aded94b6f22a8e22faf597608da9d045e5327"
39
+ "gitHead": "9c9f7a9e6a715010e0746e271e930d92e64e16d2"
40
40
  }
@@ -1,11 +1,15 @@
1
1
  <svelte:options tag={null} />
2
2
 
3
- <script lang="typescript">
3
+ <script lang="ts">
4
4
  import { getDevice } from 'rvhelper';
5
5
  import { logOutIcon } from './../icons/iconService';
6
+ import { _, addNewMessages, setLocale, setupI18n } from './i18n';
7
+ import { GeneralLogoutTranslations } from './translations';
8
+
6
9
  export let endpoint:String = '';
7
10
  export let session:String = '';
8
11
  export let buttonlocation:string = '';
12
+ export let lang:string = '';
9
13
 
10
14
  let hasErrors:Boolean = false;
11
15
 
@@ -13,6 +17,12 @@
13
17
  let isMobile = (getDevice(userAgent) === 'PC') ? false : true;
14
18
  const mediaQuery = window.matchMedia('(min-width: 768px)');
15
19
 
20
+ // setupI18n({ withLocale: 'en', translations: {}});
21
+
22
+ Object.keys(GeneralLogoutTranslations).forEach((item:any) => {
23
+ addNewMessages(item, GeneralLogoutTranslations[item]);
24
+ });
25
+
16
26
  const logout = () => {
17
27
  let reqHeaders = new Headers();
18
28
 
@@ -48,7 +58,12 @@
48
58
  return hasErrors;
49
59
  }
50
60
 
61
+ const initialLoad = () => {
62
+ setLocale(lang);
63
+ }
64
+
51
65
  $: endpoint && session && buttonlocation && checkAttrs();
66
+ $: lang && initialLoad();
52
67
  </script>
53
68
 
54
69
  {#if buttonlocation === 'PlayerAccountMenu'}
@@ -57,12 +72,12 @@
57
72
  <svg id="bbfaf345-72af-4296-bf4b-2fd41fc03d5d" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 150"><defs><style>.a88316b4-2478-4a69-b2eb-d32a5fb419dd{fill:#fff;}</style></defs><path class="a88316b4-2478-4a69-b2eb-d32a5fb419dd" d="M147.16,67.69,115.42,36a9.6,9.6,0,1,0-13.58,13.58l15.32,15.31H49.58a9.63,9.63,0,1,0,0,19.26h67.58L101.84,99.42a9.64,9.64,0,0,0,6.79,16.43,9.41,9.41,0,0,0,6.79-2.85l31.74-31.73a9.53,9.53,0,0,0,0-13.58Z"/><path class="a88316b4-2478-4a69-b2eb-d32a5fb419dd" d="M45.16,122.16H19.26V26.79H45.32a9.63,9.63,0,1,0,0-19.26H9.63A9.56,9.56,0,0,0,0,17.16V131.63a9.57,9.57,0,0,0,9.63,9.64H45.32A9.57,9.57,0,0,0,55,131.63a9.78,9.78,0,0,0-9.79-9.47Z"/></svg>
58
73
  </span>
59
74
  {#if !isMobile}
60
- <span class="PlayerLogoutText">Logout</span>
75
+ <span class="PlayerLogoutText">{$_('logout.logoutButton')}</span>
61
76
  {/if}
62
77
  </p>
63
78
  {:else}
64
79
  <div class="GeneralLogout">
65
- <button on:click={() => logout()}><span>Logout</span></button>
80
+ <button on:click={() => logout()}><span>{$_('logout.logoutButton')}</span></button>
66
81
  </div>
67
82
  {/if}
68
83
 
package/src/i18n.js ADDED
@@ -0,0 +1,27 @@
1
+ import {
2
+ dictionary,
3
+ locale,
4
+ addMessages,
5
+ _
6
+ } from 'svelte-i18n';
7
+
8
+ function setupI18n({ withLocale: _locale, translations }) {
9
+ locale.subscribe((data) => {
10
+ if (data == null) {
11
+ dictionary.set(translations);
12
+ locale.set(_locale);
13
+ }
14
+ }); // maybe we will need this to make sure that the i18n is set up only once
15
+ /*dictionary.set(translations);
16
+ locale.set(_locale);*/
17
+ }
18
+
19
+ function addNewMessages(lang, dict) {
20
+ addMessages(lang, dict);
21
+ }
22
+
23
+ function setLocale(_locale) {
24
+ locale.set(_locale);
25
+ }
26
+
27
+ export { _, setupI18n, addNewMessages, setLocale };
@@ -0,0 +1,17 @@
1
+ export const GeneralLogoutTranslations = {
2
+ en: {
3
+ logout: {
4
+ logoutButton: 'Logout',
5
+ }
6
+ },
7
+ tr: {
8
+ logout: {
9
+ logoutButton: 'Çıkış Yap',
10
+ }
11
+ },
12
+ ro: {
13
+ logout: {
14
+ logoutButton: 'Iesire',
15
+ }
16
+ },
17
+ };