@everymatrix/general-player-login-form 0.0.213 → 0.0.217

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/general-player-login-form",
3
- "version": "0.0.213",
3
+ "version": "0.0.217",
4
4
  "main": "dist/general-player-login-form.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": "0b49e65f747ec6eaac6ca9d4a4e7ee9702980bfc"
39
+ "gitHead": "eece4cbb47122ec254298d89beb7fdb184124cdc"
40
40
  }
@@ -1,8 +1,10 @@
1
1
  <svelte:options tag={null} />
2
2
 
3
- <script lang="typescript">
3
+ <script lang="ts">
4
4
  import { onMount } from "svelte";
5
5
  import { isMobile } from 'rvhelper';
6
+ import { _, addNewMessages, setLocale, setupI18n } from './i18n';
7
+ import { LoginForm } from './translations';
6
8
 
7
9
  import {
8
10
  isNative,
@@ -12,6 +14,7 @@
12
14
 
13
15
  export let imagedesktop:string = '';
14
16
  export let captchakey:string = '';
17
+ export let lang:string = '';
15
18
 
16
19
  let mobileView:boolean = false;
17
20
  let userAgent:string = window.navigator.userAgent;
@@ -36,7 +39,11 @@
36
39
 
37
40
  let nativeCredentials:any = {};
38
41
 
39
- const captchaKey = '6Lc7w8YcAAAAAEMHc_VNN9bqfVnILoUOHSHyZ0yn';
42
+ // setupI18n({ withLocale: 'en', translations: {}});
43
+
44
+ Object.keys(LoginForm).forEach((item:any) => {
45
+ addNewMessages(item, LoginForm[item]);
46
+ });
40
47
 
41
48
  const regexValidators = {
42
49
  user: /^(?!(?:.*\d){9})(?=(?:.*[a-zA-Z]){2})^[a-zA-Z\d]*$/,
@@ -141,6 +148,10 @@
141
148
  }
142
149
  }
143
150
 
151
+ const initialLoad = () => {
152
+ setLocale(lang);
153
+ }
154
+
144
155
  onMount(async () => {
145
156
  window.addEventListener('message', messageHandler, false);
146
157
  window.postMessage({ type: "LoginRegisterModalActive" }, window.location.href);
@@ -177,6 +188,8 @@
177
188
  window.removeEventListener('message', messageHandler);
178
189
  }
179
190
  });
191
+
192
+ $: lang && initialLoad();
180
193
  </script>
181
194
 
182
195
  <svelte:head>
@@ -193,19 +206,19 @@
193
206
  <div class="FormContainer {mobileView ? 'FormMobileContainer' : ''}">
194
207
  <div class="FormLeftSide">
195
208
  <div class="FormHeader">
196
- <h4 class="FormHeaderTitle">Welcome</h4>
197
- <p class="FormHeaderSubtitle">Don't have an account yet? <span class="FormRegisterCallToAction" on:click={() => switchToRegister()}>Register now</span></p>
209
+ <h4 class="FormHeaderTitle">{$_('loginForm.loginTitle')}</h4>
210
+ <p class="FormHeaderSubtitle">{$_('loginForm.loginSubtitle')} <span class="FormRegisterCallToAction" on:click={() => switchToRegister()}>{$_('loginForm.loginSubtitleRegister')}</span></p>
198
211
  </div>
199
212
  <div class="FormContent">
200
213
  <div class="UserContainer {invalidName ? 'InvalidField' : ''}">
201
- <label for="UserName">Username or Email:<span class="FormRequired">*</span></label>
214
+ <label for="UserName">{$_('loginForm.loginUsername')}:<span class="FormRequired">*</span></label>
202
215
  <input bind:value={userValue} on:keyup={validateUserName} type="text" id="UserName" />
203
216
  {#if invalidName}
204
- <p class="InvalidInput">Name must be at least 2 characters long, and contain no special characters. Email should contain '@' and a 2-3 letter long domain.</p>
217
+ <p class="InvalidInput">{$_('loginForm.loginUsernameError')}</p>
205
218
  {/if}
206
219
  </div>
207
220
  <div class="PasswordContainer {invalidPassword ? 'InvalidField' : ''}">
208
- <label for="Password">Password:<span class="FormRequired">*</span></label>
221
+ <label for="Password">{$_('loginForm.loginPassword')}:<span class="FormRequired">*</span></label>
209
222
  <input bind:value={userPassword} on:keyup={validatePassword} type="password" id="Password" bind:this={passwordVisibilityToggle} />
210
223
  {#if isPasswordVisible}
211
224
  <svg on:click={() => hidePassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.844" height="12.887" viewBox="0 0 18.844 12.887"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-110.856 -23.242)"><circle class="a" cx="0.05" cy="0.05" r="0.05" transform="translate(121.017 31.148)"/><g transform="translate(117.499 27.37)"><path class="a" d="M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z" transform="translate(-142.164 -39.123)"/><path class="a" d="M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z" transform="translate(-136.413 -42.068)"/></g><g transform="translate(110.856 24.899)"><path class="a" d="M122.538,42.061a7.043,7.043,0,0,1-2.325.53,10.373,10.373,0,0,1-4.393-1.482,36.509,36.509,0,0,1-3.873-2.391.13.13,0,0,1,0-.208,44.141,44.141,0,0,1,3.873-2.651c.394-.233.768-.437,1.13-.622l-.686-.838c-.322.167-.651.347-.99.55a37.989,37.989,0,0,0-3.977,2.729,1.21,1.21,0,0,0-.442.962,1.1,1.1,0,0,0,.494.936,34.416,34.416,0,0,0,3.977,2.469,11.468,11.468,0,0,0,4.886,1.611,8.427,8.427,0,0,0,3.039-.725Z" transform="translate(-110.856 -33.157)"/><path class="a" d="M149.119,34.14a45.875,45.875,0,0,0-4.055-2.729,20.541,20.541,0,0,0-2.547-1.248,5.6,5.6,0,0,0-4.79-.017l.7.856a5.254,5.254,0,0,1,1.672-.346,10.072,10.072,0,0,1,4.445,1.663,34.132,34.132,0,0,1,3.925,2.651.13.13,0,0,1,0,.208,40.2,40.2,0,0,1-3.925,2.391c-.179.092-.352.176-.525.26l.684.835c.1-.054.2-.1.309-.159a36.356,36.356,0,0,0,4.055-2.469,1.067,1.067,0,0,0,.52-.936A1.159,1.159,0,0,0,149.119,34.14Z" transform="translate(-130.743 -29.617)"/></g><rect class="a" width="0.972" height="15.861" rx="0.486" transform="translate(114.827 23.858) rotate(-39.315)"/></g></svg>
@@ -213,14 +226,14 @@
213
226
  <svg on:click={() => showPassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.843" height="10.5" viewBox="0 0 18.843 10.5"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-14.185 -27.832)"><path class="a" d="M23.541,38.332a11.467,11.467,0,0,1-4.886-1.611,34.413,34.413,0,0,1-3.976-2.469,1.1,1.1,0,0,1-.494-.936,1.21,1.21,0,0,1,.442-.962A37.986,37.986,0,0,1,18.6,29.625a16.06,16.06,0,0,1,2.521-1.248,6.862,6.862,0,0,1,2.417-.546,6.862,6.862,0,0,1,2.417.546,20.541,20.541,0,0,1,2.547,1.248,45.872,45.872,0,0,1,4.054,2.729,1.159,1.159,0,0,1,.468.962,1.067,1.067,0,0,1-.52.936,36.353,36.353,0,0,1-4.054,2.469A11.2,11.2,0,0,1,23.541,38.332Zm0-9.46a9.813,9.813,0,0,0-4.392,1.663,44.138,44.138,0,0,0-3.873,2.651.13.13,0,0,0,0,.208,36.5,36.5,0,0,0,3.873,2.391,10.372,10.372,0,0,0,4.392,1.481,11.051,11.051,0,0,0,4.444-1.481,40.2,40.2,0,0,0,3.925-2.391.13.13,0,0,0,0-.208h0a34.132,34.132,0,0,0-3.925-2.651A10.072,10.072,0,0,0,23.541,28.872Z" transform="translate(0)"/><circle class="a" cx="2.779" cy="2.779" r="2.779" transform="translate(20.827 30.303)"/></g></svg>
214
227
  {/if}
215
228
  {#if invalidPassword}
216
- <p class="InvalidInput">Password must be 8-20 characters long, and contain at least 1 uppercase letter, 1 number and 1 special character.</p>
229
+ <p class="InvalidInput">{$_('loginForm.loginPasswordError')}</p>
217
230
  {/if}
218
231
  </div>
219
232
  {#if errorMessage}
220
233
  <p class="ErrorMessage">{errorMessage}</p>
221
234
  {/if}
222
- <button class="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid}>Sign In</button>
223
- <button class="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>I forgot my password</button>
235
+ <button class="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid}>{$_('loginForm.loginButton')}</button>
236
+ <button class="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>{$_('loginForm.loginForgotPassword')}</button>
224
237
  </div>
225
238
  </div>
226
239
  {#if !mobileView}
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,41 @@
1
+ export const LoginForm = {
2
+ en: {
3
+ loginForm: {
4
+ loginTitle: 'Welcome',
5
+ loginSubtitle: 'Don\'t have an account yet?',
6
+ loginSubtitleRegister: 'Register now',
7
+ loginUsername: 'Username or Email',
8
+ loginUsernameError: 'Name must be at least 2 characters long and contain no special characters. Email should contain \'@\' and a 2-3 letter long domain.',
9
+ loginPassword: 'Password',
10
+ loginPasswordError: 'Password must be 8-20 characters long and contain at least 1 uppercase letter, 1 number and 1 special character.',
11
+ loginButton: 'Sign in',
12
+ loginForgotPassword: 'I forgot my password'
13
+ }
14
+ },
15
+ tr: {
16
+ loginForm: {
17
+ loginTitle: 'Hoş geldin',
18
+ loginSubtitle: 'Henüz bir hesabınız yok mu?',
19
+ loginSubtitleRegister: 'Şimdi üye Ol',
20
+ loginUsername: 'Kullanıcı adı ya da email',
21
+ loginUsernameError: 'Ad en az 2 karakter uzunluğunda olmalı ve özel karakter içermemelidir. E-posta \'@\' ve 2-3 harf uzunluğunda bir etki alanı içermelidir.',
22
+ loginPassword: 'Parola',
23
+ loginPasswordError: 'Şifre 8-20 karakter uzunluğunda olmalı ve en az 1 büyük harf, 1 rakam ve 1 özel karakter içermelidir.',
24
+ loginButton: 'Sign in',
25
+ loginForgotPassword: 'I forgot my password'
26
+ }
27
+ },
28
+ ro: {
29
+ loginForm: {
30
+ loginTitle: 'Bine ai venit',
31
+ loginSubtitle: 'Nu ai cont?',
32
+ loginSubtitleRegister: 'Inregistreaza-te acum',
33
+ loginUsername: 'Utilizator sau Email',
34
+ loginUsernameError: 'Utilizatorul trebuie sa aiba minim 2 litere si sa nu contina caractere speciale. Email-ul trebuie sa contina \'@\' si domeniul sa aiba 2-3 litere lungime.',
35
+ loginPassword: 'Parola',
36
+ loginPasswordError: 'Parola trebuie sa aiba o lungime de 8-20 de caractere, sa contina cel putin o litera mare, o cifra si un caracter special.',
37
+ loginButton: 'Autentificare',
38
+ loginForgotPassword: 'Mi-am uitat parola'
39
+ }
40
+ },
41
+ };