@everymatrix/player-account-menu 0.0.197 → 0.0.201

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/player-account-menu",
3
- "version": "0.0.197",
3
+ "version": "0.0.201",
4
4
  "main": "dist/player-account-menu.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": "89d693d3429e3dc0d6e642537452c8faa0ca008a"
39
+ "gitHead": "71051531499cfea745b53a0f7c0a77a252990ae7"
40
40
  }
@@ -4,11 +4,14 @@
4
4
  import { getDevice } from 'rvhelper';
5
5
  import { onMount } from "svelte";
6
6
  import { generalIcon } from './../icons/iconService';
7
+ import { _, addNewMessages, setLocale } from './i18n';
8
+ import { PlayerMyAccountTranslations } from './translations';
7
9
  import '@everymatrix/general-logout';
8
10
 
9
11
  export let endpoint:string = '';
10
12
  export let session:string = '';
11
13
  export let playerid:string = '';
14
+ export let lang:string = 'en';
12
15
 
13
16
  let isLoading:boolean = false;
14
17
 
@@ -25,6 +28,11 @@
25
28
 
26
29
  const mediaQuery = window.matchMedia('(min-width: 768px)');
27
30
 
31
+ Object.keys(PlayerMyAccountTranslations).forEach((item) => {
32
+ addNewMessages(item, PlayerMyAccountTranslations[item]);
33
+ });
34
+
35
+
28
36
  onMount(() => {
29
37
  window.addEventListener('message', messageHandler, false);
30
38
 
@@ -104,11 +112,12 @@
104
112
  }
105
113
 
106
114
  const initialLoad = () => {
115
+ setLocale(lang);
107
116
  adjustContentToDevice();
108
117
  getPlayerInfo();
109
118
  }
110
119
 
111
- $: endpoint && session && playerid && initialLoad();
120
+ $: endpoint && session && playerid && lang && initialLoad();
112
121
 
113
122
  </script>
114
123
 
@@ -118,7 +127,7 @@
118
127
  <div class="PlayerAccountMenuContainer {isMobile ? 'PlayerAccountMobileContainer' : ''} {mediaQuery.matches && isMobile ? 'PlayerAccountTabletContainer' : ''}">
119
128
  <div class="PlayerAccountMenuHeader">
120
129
  {#if isMobile}
121
- <h3 class="PlayerAccountMenuCategoryTitle">My Account</h3>
130
+ <h3 class="PlayerAccountMenuCategoryTitle">{$_('myAccount.title')}</h3>
122
131
  {/if}
123
132
  <p class="PlayerAccountMenuUser">{profileUsername}</p>
124
133
  <p class="PlayerAccountMenuEmail">{profileEmail}</p>
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,12 @@
1
+ export const PlayerMyAccountTranslations = {
2
+ en: {
3
+ myAccount: {
4
+ title: `My Account`,
5
+ }
6
+ },
7
+ ro: {
8
+ myAccount: {
9
+ title: `My Account`,
10
+ }
11
+ }
12
+ };