@everymatrix/player-profile-info 0.0.200 → 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-profile-info",
3
- "version": "0.0.200",
3
+ "version": "0.0.201",
4
4
  "main": "dist/player-profile-info.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": "1575292cd20d511a1f4ebe038656d86deab2c7e0"
39
+ "gitHead": "71051531499cfea745b53a0f7c0a77a252990ae7"
40
40
  }
@@ -3,8 +3,11 @@
3
3
  <script lang="typescript">
4
4
  import { onMount } from 'svelte';
5
5
  import { getDevice } from 'rvhelper';
6
+ import { _, addNewMessages, setLocale } from './i18n';
7
+ import { PlayerProfileTranslations } from './translations';
6
8
 
7
9
  export let endpoint:string = '';
10
+ export let lang:string = 'en';
8
11
 
9
12
  let isLoading:boolean = false;
10
13
  let userAgent:String = window.navigator.userAgent;
@@ -25,6 +28,9 @@
25
28
 
26
29
  let showConfirmSave:boolean = false;
27
30
 
31
+ Object.keys(PlayerProfileTranslations).forEach((item:any) => {
32
+ addNewMessages(item, PlayerProfileTranslations[item]);
33
+ });
28
34
  const mediaQuery = window.matchMedia('(min-width: 768px)');
29
35
 
30
36
  // needed to keep track of data changes
@@ -61,7 +67,7 @@
61
67
  currency: "EUR",
62
68
  email: "email@here.com",
63
69
  firstname: "Joe",
64
- gender: "M",
70
+ userTitles: "M",
65
71
  lastname: "Johnson",
66
72
  mobile: {prefix: "+00", number: "00000000"},
67
73
  postalCode: "i.e.: 465531",
@@ -71,7 +77,7 @@
71
77
  username: "Username"
72
78
  };
73
79
 
74
- let {address1, birth, city, country, currency, mobile, email, firstname, gender, language, lastname, postalCode, securityAnswer, securityQuestion, username, consents} = profileDetails;
80
+ let {address1, birth, city, country, currency, mobile, email, firstname, userTitles, language, lastname, postalCode, securityAnswer, securityQuestion, username, consents} = profileDetails;
75
81
 
76
82
  const messageHandler = (e:any) => {
77
83
  if (e.data) {
@@ -89,7 +95,7 @@
89
95
  language = profileDetails.language;
90
96
  birth = profileDetails.birth.day + '/' + profileDetails.birth.month + '/' + profileDetails.birth.year;
91
97
  currency = profileDetails.currency;
92
- gender = profileDetails.gender;
98
+ userTitles = profileDetails.title;
93
99
  country = profileDetails.country;
94
100
  // match country code to country name
95
101
  selectedCountry = countriesArray.find(country => country.Alpha2Code === profileDetails.country);
@@ -213,6 +219,10 @@
213
219
  }
214
220
  }
215
221
 
222
+ const initialLoad = () => {
223
+ setLocale(lang);
224
+ }
225
+
216
226
  onMount(() => {
217
227
  window.addEventListener('message', messageHandler, false);
218
228
  return () => {
@@ -220,6 +230,7 @@
220
230
  }
221
231
  });
222
232
 
233
+ $: lang && initialLoad();
223
234
  $: endpoint && getCountriesList();
224
235
  $: endpoint && getPhoneCodes();
225
236
  </script>
@@ -236,22 +247,22 @@
236
247
  <path class="aaa" d="M7.5,0,6.136,1.364,11.3,6.526H0V8.474H11.3L6.136,13.636,7.5,15,15,7.5Z" transform="translate(15 15) rotate(180)"/>
237
248
  </g></g>
238
249
  </svg>
239
- <h2 class="MyAccountCategoryTitleMobile">Profile Info</h2>
250
+ <h2 class="MyAccountCategoryTitleMobile">{$_('playerProfile.title')}</h2>
240
251
  </div>
241
252
  {/if}
242
253
 
243
- <h2 class="MyAccountCategoryTitle {isMobile ? 'MyAccountCategoryTitleNone' : ''}">Profile Info</h2>
254
+ <h2 class="MyAccountCategoryTitle {isMobile ? 'MyAccountCategoryTitleNone' : ''}">{$_('playerProfile.title')}</h2>
244
255
 
245
256
  <div class="PlayerNotificationsHeader">
246
- <h3>Personal Details</h3>
257
+ <h3>{$_('playerProfile.personalDetails')}</h3>
247
258
  </div>
248
259
  <section class="PlayerDetailsContent">
249
260
  <div class="PlayerInfoBox">
250
- <label>User name:</label>
261
+ <label>{$_('playerProfile.userName')}</label>
251
262
  <input type="text" class="FieldDisabled" value={username} readonly />
252
263
  </div>
253
264
  <div class="PlayerInfoBox">
254
- <label>Phone:</label>
265
+ <label>{$_('playerProfile.userPhone')}</label>
255
266
  <div class="PlayerPhoneNumber">
256
267
  <select bind:value={playerPrefix} on:change={() => checkForChanges()}>
257
268
  {#each prefixesArray as pref}
@@ -266,86 +277,86 @@
266
277
  </div>
267
278
  </div>
268
279
  <div class="PlayerInfoBox">
269
- <label>Email:</label>
280
+ <label>{$_('playerProfile.userEmail')}</label>
270
281
  <input type="email" class="FieldDisabled" value={email} readonly />
271
282
  </div>
272
283
  <div class="PlayerInfoBox">
273
- <label>Security Question:</label>
284
+ <label>{$_('playerProfile.securityQuestion')}</label>
274
285
  <input type="text" bind:value={playerQuestion} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? securityQuestion : ''} />
275
286
  </div>
276
287
  <div class="PlayerInfoBox">
277
- <label>First name:</label>
288
+ <label>{$_('playerProfile.firstName')}</label>
278
289
  <input type="text" class="FieldDisabled" value={firstname} readonly />
279
290
  </div>
280
291
  <div class="PlayerInfoBox">
281
- <label>Security Answer:</label>
292
+ <label>{$_('playerProfile.securityAnswer')}</label>
282
293
  <input type="text" bind:value={playerAnswer} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? securityAnswer : ''} />
283
294
  </div>
284
295
  <div class="PlayerInfoBox">
285
- <label>Last Name:</label>
296
+ <label>{$_('playerProfile.lastName')}</label>
286
297
  <input type="text" class="FieldDisabled" value={lastname} readonly />
287
298
  </div>
288
299
  <div class="PlayerInfoBox">
289
- <label>Date of birth:</label>
300
+ <label>{$_('playerProfile.dateOfBirth')}</label>
290
301
  <input type="text" class="FieldDisabled" value={birth} readonly />
291
302
  </div>
292
303
  <div class="PlayerInfoBox">
293
- <label>Currency:</label>
304
+ <label>{$_('playerProfile.currency')}</label>
294
305
  <input type="text" class="FieldDisabled" value={currency} readonly />
295
306
  </div>
296
307
  <div class="PlayerInfoBox">
297
- <label>Title:</label>
298
- <input type="text" class="FieldDisabled" value={gender} readonly />
308
+ <label>{$_('playerProfile.userTitle')}</label>
309
+ <input type="text" class="FieldDisabled" value={userTitles} readonly />
299
310
  </div>
300
311
  </section>
301
312
 
302
313
  <div class="PlayerLocationHeader">
303
- <h3>Location Details</h3>
314
+ <h3>{$_('playerProfile.locationDetails')}</h3>
304
315
  </div>
305
316
  <section class="PlayerLocationContent">
306
317
  <div class="PlayerInfoBox">
307
- <label>Country:</label>
318
+ <label>{$_('playerProfile.userCountry')}</label>
308
319
  <input type="text" class="PlayerCountry FieldDisabled" placeholder={country} value={selectedCountry.Name} readonly />
309
320
  </div>
310
321
  <div class="PlayerInfoBox">
311
- <label>City:</label>
322
+ <label>{$_('playerProfile.userCity')}</label>
312
323
  <input bind:this={playerCity} type="text" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? city : ''} value={noPlayerData ? '' : initialValuesArray.city} />
313
324
  </div>
314
325
  <div class="PlayerInfoBox">
315
- <label>Address:</label>
326
+ <label>{$_('playerProfile.userAddress')}</label>
316
327
  <input bind:this={playerAddress} placeholder={address1} type="text" on:keyup={() => checkForChanges()} value={noPlayerData ? '' : initialValuesArray.address} />
317
328
  </div>
318
329
  <div class="PlayerInfoBox">
319
- <label>Postal Code:</label>
330
+ <label>{$_('playerProfile.userPostalCode')}</label>
320
331
  <input bind:this={playerPostalCode} type="number" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? postalCode : ''} value={noPlayerData ? '' : initialValuesArray.postalCode} />
321
332
  </div>
322
333
  </section>
323
334
 
324
335
  <div class="PlayerNotificationsHeader">
325
- <h3>Notifications</h3>
336
+ <h3>{$_('playerProfile.userNotifications')}</h3>
326
337
  </div>
327
338
  <section class="PlayerNotificationsCheckboxArea">
328
339
  <div class="PlayerNotificationBox">
329
340
  <label for="SMSNotification">
330
341
  <input bind:checked={giveConsentSMS} on:change={checkForChanges} type="checkbox" id="SMSNotification" name="Enable SMS notifications" />
331
342
  <span class="Checkmark"></span>
332
- <span>Enable SMS notifications</span>
343
+ <span>{$_('playerProfile.userSMSNotification')}</span>
333
344
  </label>
334
345
  </div>
335
346
  <div class="PlayerNotificationBox">
336
347
  <label for="EmailNotification">
337
348
  <input bind:checked={giveConsentEmail} on:change={checkForChanges} type="checkbox" id="EmailNotification" name="Enable Emails" />
338
349
  <span class="Checkmark"></span>
339
- <span>Enable Emails</span>
350
+ <span>{$_('playerProfile.userEmailNotification')}</span>
340
351
  </label>
341
352
  </div>
342
353
  </section>
343
354
  <section class="PlayerDetailsButtonsArea {isMobile ? 'PlayerDetailsButtonsAreaMobile' : ''}">
344
- <div class="PlayerDetailsSaveButton {differencesExist && isValid ? '' : 'PlayerButtonDisabled'}" on:click={() => updatePlayerInfo()}>Save Changes</div>
355
+ <div class="PlayerDetailsSaveButton {differencesExist && isValid ? '' : 'PlayerButtonDisabled'}" on:click={() => updatePlayerInfo()}>{$_('playerProfile.userProfileSaveChanges')}</div>
345
356
  </section>
346
357
  {#if showConfirmSave}
347
358
  <section class="PlayerDetailsConfirmSave">
348
- <p class="PlayerDetailsConfirmSaveText">Your changes have been saved!</p>
359
+ <p class="PlayerDetailsConfirmSaveText">{$_('playerProfile.userProfileConfirmationMessage')}</p>
349
360
  </section>
350
361
  {/if}
351
362
  </form>
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,54 @@
1
+ export const PlayerProfileTranslations = {
2
+ en: {
3
+ playerProfile: {
4
+ title: `Profile Info`,
5
+ personalDetails: `Personal Details`,
6
+ userName: `User name:`,
7
+ userPhone: `Phone:`,
8
+ userEmail: `Email:`,
9
+ securityQuestion: `Security Question:`,
10
+ firstName: `First name:`,
11
+ securityAnswer: `Security Answer:`,
12
+ lastName: `Last Name:`,
13
+ dateOfBirth: `Date of birth:`,
14
+ currency: `Currency:`,
15
+ userTitle: `Title:`,
16
+ locationDetails: `Location Details`,
17
+ userCountry: `Country:`,
18
+ userCity: `City:`,
19
+ userAddress: `Address:`,
20
+ userPostalCode: `Postal Code:`,
21
+ userNotifications: `Notifications`,
22
+ userSMSNotification: `Enable SMS notifications`,
23
+ userEmailNotification: `Enable Emails`,
24
+ userProfileSaveChanges: `Save Changes`,
25
+ userProfileConfirmationMessage: `Your changes have been saved!`
26
+ }
27
+ },
28
+ ro: {
29
+ playerProfile: {
30
+ title: `Profile Info`,
31
+ personalDetails: `Personal Details`,
32
+ userName: `User name:`,
33
+ userPhone: `Phone:`,
34
+ userEmail: `Email:`,
35
+ securityQuestion: `Security Question:`,
36
+ firstName: `First name:`,
37
+ securityAnswer: `Security Answer:`,
38
+ lastName: `Last Name:`,
39
+ dateOfBirth: `Date of birth:`,
40
+ currency: `Currency:`,
41
+ userTitle: `Title:`,
42
+ locationDetails: `Location Details`,
43
+ userCountry: `Country:`,
44
+ userCity: `City:`,
45
+ userAddress: `Address:`,
46
+ userPostalCode: `Postal Code:`,
47
+ userNotifications: `Notifications`,
48
+ userSMSNotification: `Enable SMS notifications`,
49
+ userEmailNotification: `Enable Emails`,
50
+ userProfileSaveChanges: `Save Changes`,
51
+ userProfileConfirmationMessage: `Your changes have been saved!`
52
+ }
53
+ }
54
+ };