Quellcode durchsuchen

localization part

Nikolay Suslov vor 4 Jahren
Ursprung
Commit
bcb9baf64c
6 geänderte Dateien mit 83 neuen und 65 gelöschten Zeilen
  1. 4 2
      public/app.js
  2. 18 7
      public/lib/locale/en/en.json
  3. 20 13
      public/lib/locale/ru/ru.json
  4. 6 6
      public/lib/widgets.js
  5. 5 7
      public/web/header.js
  6. 30 30
      public/web/index-app.js

+ 4 - 2
public/app.js

@@ -38,8 +38,10 @@ class App {
 
     import('/lib/polyglot/language.js').then(res => {
       window._LangManager = new res.default;
-      _LangManager.setLanguage();
-    }).then(res => {
+      return new Promise(r=>r(_LangManager.setLanguage())) }).then(res=>{
+        window._l = _LangManager.language;
+      })
+    .then(res => {
       return import('/web/index-app.js');
     }).then(res => {
       window.IndexApp = res.default;

+ 18 - 7
public/lib/locale/en/en.json

@@ -1,17 +1,29 @@
 {
+    "header_home": "Home",
+    "conn_settings":"Connection settings",
+    "help":"Help",
+    "en":"English",
+    "ru":"Русский",
     "home": "Home",
     "App": "App",
     "clone proto": "Clone",
     "start": "Start",
     "users": "Users",
-    "welcome": "Welcome!",
+    "welcome": "Welcome",
     "login": "Login",
     "password": "Password",
-   "sign up": "sign up",
-   "sign in": "sign in",
-   "looking for worlds made by other users": "Looking for Worlds made by other Users!",
-   "world protos": "world protos",
-    "world states": "world states",
+   "sign up": "Sign up",
+   "sign in": "Sign in",
+   "sign out": "Sign out",
+   "profile": "My profile",
+   "show worlds": "Search for Worlds, made by other Users!",
+   "my world protos": "My protos",
+    "my world states": "My worlds",
+   "world protos": "protos",
+    "world states": "worlds",
+    "protos for": "World protos by - ",
+    "states for": "Worlds by  - ",
+    "enter user name": "Enter user name",
     "details": "details",
     "online now": "online now",
     "scene": "Scene",
@@ -53,5 +65,4 @@
      "node methods": "NODE METHODS",
      "proto methods": "PROTO METHODS",
      "methods name": "Methods name"
-       
 }

+ 20 - 13
public/lib/locale/ru/ru.json

@@ -1,19 +1,31 @@
 {
+    "header_home": "Домой",
+    "conn_settings":"Свойства подключения",
+    "help":"Помощь",
+    "en":"English",
+    "ru":"Русский",
     "home": "Дом",
     "App": "Программа",
     "clone proto": "Клонировать",
     "start": "Запустить",
     "users": "Пользователи",
-    "welcome": "Добро пожаловать!",
+    "welcome": "Добро пожаловать",
     "login": "Имя",
     "password": "Пароль",
-    "sign up": "подписаться",
-    "sign in": "войти в систему",
-    "looking for worlds made by other users": "Смотреть Миры, созданные другими пользователями!",
-    "world protos": "прототипы мира",
-    "world states": "состояния мира",
-    "details": "детали",
-    "online now": "сейчас в сети",
+    "sign up": "Зарегистрироваться",
+    "sign in": "Войти",
+    "sign out": "Выйти",
+    "profile": "Мой профиль",
+    "show worlds": "Найти Миры, созданные другими пользователями!",
+    "my world protos": "Мои прототипы",
+    "my world states": "Мои миры",
+    "world protos": "Прототипы",
+    "world states": "Миры",
+    "protos for": "Прототипы миров пользователя: ",
+    "states for": "Миры пользователя: ",
+    "enter user name": "Введите имя пользователя",
+    "details": "Подробнее",
+    "online now": "онлайн",
     "scene": "Сцена",
     "create": "Создать",
     "code editor": "Редактор кода",
@@ -53,9 +65,4 @@
      "node methods": "методы узла",
      "proto methods": "методы прототипа",
      "methods name": "имя метода"
-
-     
-
-
-
 }

+ 6 - 6
public/lib/widgets.js

@@ -1145,11 +1145,11 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                                         {
                                             $type: "span",
                                             class: "mdc-typography--headline5",
-                                            $text: "Login: "
+                                            $text: _l.t("login") + ": "
                                         },
                                         window._app.widgets.inputTextFieldOutlined({
                                             "id": 'aliasInput',
-                                            "label": "Login",
+                                            "label": _l.t("login"),
                                             "value": this._alias,
                                             "type": "text",
                                             "init": function () {
@@ -1165,11 +1165,11 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                                         {
                                             $type: "span",
                                             class: "mdc-typography--headline5",
-                                            $text: "Password: "
+                                            $text: _l.t("password") + ": "
                                         },
                                         window._app.widgets.inputTextFieldOutlined({
                                             "id": 'passwordInput',
-                                            "label": "Password",
+                                            "label": _l.t("password"),
                                             "value": this._pass,
                                             "type": "password",
                                             "init": function () {
@@ -1184,7 +1184,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                                     $components: [
                                         window._app.widgets.buttonRaised(
                                             {
-                                                "label": 'Sign UP',
+                                                "label": _l.t("sign up"),
                                                 "onclick": function (e) {
                                                     e.preventDefault();
     
@@ -1225,7 +1225,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                                         _app.widgets.space,
                                         window._app.widgets.buttonRaised(
                                             {
-                                                "label": 'Sign IN',
+                                                "label": _l.t("sign in"),
                                                 "onclick": function (e) {
                                                     e.preventDefault();
                                                     let alias = this._aliasField.value;

+ 5 - 7
public/web/header.js

@@ -8,8 +8,6 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
 class Header {
     constructor() {
         console.log("header constructor");
-        this.language = _LangManager.language;
-
     }
 
     init() {
@@ -49,7 +47,7 @@ class Header {
                                             $type: "a",
                                             style: "cursor:pointer; margin-right: 10px",
                                             class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
-                                            $text: "Home",
+                                            $text: _l.t("header_home"),//"Home",
                                             //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
                                             onclick: function (e) {
                                                 window.location.pathname = '/'
@@ -61,7 +59,7 @@ class Header {
                                             $type: "a",
                                             style: "cursor:pointer; margin-right: 10px",
                                             class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
-                                            $text: "Connection settings",
+                                            $text: _l.t("conn_settings"),
                                             //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
                                             onclick: function (e) {
                                                 window.location.pathname = '/settings'
@@ -74,7 +72,7 @@ class Header {
                                             $type: "a",
                                             style: "cursor:pointer; margin-right: 40px",
                                             class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
-                                            $text: "Help",
+                                            $text: _l.t("help"),
                                             //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
                                             href: 'https://www.krestianstvo.org/docs/sdk3'
 
@@ -84,7 +82,7 @@ class Header {
                                             id: 'ruLang',
                                             style: "cursor:pointer; margin-right: 10px",
                                             class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
-                                            $text: "RU",
+                                            $text: _l.t("ru"),
                                             //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
                                             onclick: function (e) {
                                                 _LangManager.locale = 'ru';
@@ -97,7 +95,7 @@ class Header {
                                             id: 'enLang',
                                             style: "cursor:pointer; margin-right: 10px",
                                             class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
-                                            $text: "EN",
+                                            $text: _l.t("en"),
                                             //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
                                             onclick: function (e) {
                                                 _LangManager.locale = 'en';

+ 30 - 30
public/web/index-app.js

@@ -138,7 +138,7 @@ class IndexApp {
             id: "userGUI",
             // style:"background-color: #ffeb3b",
             class: "mdc-layout-grid mdc-layout-grid--align-left",
-            _status: "Welcome!",
+            _status: _l.t("welcome") + '!',//"Welcome!",
             $init: function () {
                 //this._status = "Welcome!"
                 //this._status = 'Welcome!';
@@ -154,7 +154,7 @@ class IndexApp {
                     gui = [
                         window._app.widgets.buttonRaised(
                             {
-                                "label": 'Sign OUT',
+                                "label": _l.t("sign out"), //'Sign OUT',
                                 "onclick": function (e) {
                                     _LCSDB.user().leave();
                                     setTimeout(() => {
@@ -168,7 +168,7 @@ class IndexApp {
                         },
                         window._app.widgets.buttonStroked(
                             {
-                                "label": 'PROFILE',
+                                "label": _l.t("profile"),//'PROFILE',
                                 "onclick": function (e) {
                                     e.preventDefault();
                                     //page("/profile")
@@ -180,7 +180,7 @@ class IndexApp {
                         },
                         window._app.widgets.buttonStroked(
                             {
-                                "label": 'My World protos',
+                                "label": _l.t("my world protos"),
                                 "onclick": function (e) {
                                     e.preventDefault();
                                     let alias = _LCSDB.user().is.alias;
@@ -191,7 +191,7 @@ class IndexApp {
                             }),
                         window._app.widgets.buttonStroked(
                             {
-                                "label": 'My World states',
+                                "label": _l.t("my world states"),
                                 "onclick": function (e) {
                                     e.preventDefault();
                                     let alias = _LCSDB.user().is.alias;
@@ -268,7 +268,7 @@ class IndexApp {
                                     {
                                         $type: "h1",
                                         class: "mdc-typography--headline4",
-                                        $text: 'Worlds for user: ' + userAlias
+                                        $text: _l.t("protos for") + userAlias
                                     }
                                 ]
                             },
@@ -328,7 +328,7 @@ class IndexApp {
                                     {
                                         $type: "h1",
                                         class: "mdc-typography--headline4",
-                                        $text: 'States for ' + userAlias
+                                        $text: _l.t("states for") + userAlias
                                     }
                                 ]
                             },
@@ -352,7 +352,7 @@ class IndexApp {
 
         let alias = _LCSDB.user().is.alias;
         let userEl = document.querySelector('#userGUI');
-        userEl._status = 'Welcome ' + alias + '!';
+        userEl._status = _l.t("welcome") +', ' + alias + '!';
         //userEl.style.backgroundColor = '#e6e6e6';   
         userEl._refresh(); //$update();
 
@@ -445,7 +445,7 @@ class IndexApp {
 
                                 _app.widgets.inputTextFieldOutlined({
                                     "id": 'worldsUserName',
-                                    "label": 'Enter user name',
+                                    "label": _l.t("enter user name"),
                                     "value": defaultName,
                                     "type": "text",
                                     "init": function () {
@@ -475,7 +475,7 @@ class IndexApp {
                                 // }
                                 _app.widgets.buttonRaised(
                                     {
-                                        "label": 'World Protos',
+                                        "label":  _l.t("world protos"),
                                         "onclick": function (e) {
                                             e.preventDefault();
                                             //page("/app/worlds/protos")
@@ -489,7 +489,7 @@ class IndexApp {
                                 _app.widgets.space,
                                 _app.widgets.buttonRaised(
                                     {
-                                        "label": 'World States',
+                                        "label": _l.t("world states"),
                                         "onclick": function (e) {
                                             e.preventDefault();
                                             //page("/app/worlds/states")
@@ -531,7 +531,7 @@ class IndexApp {
                     {
                         $type: "h1",
                         class: "mdc-typography--headline4",
-                        $text: "Looking for Worlds made by other Users!"
+                        $text: _l.t("show worlds")//"Looking for Worlds made by other Users!"
                     }
                 ].concat(guiForAll, _app.widgets.p)
             }
@@ -949,7 +949,7 @@ class IndexApp {
                     userGUI.push({
                         $type: "a",
                         class: "mdc-button mdc-button--compact mdc-card__action mdc-button--outlined",
-                        $text: "Details",
+                        $text: _l.t("details"),
                         onclick: function (e) {
                             e.preventDefault();
                             window.location.pathname = "/" + desc.userAlias + '/' + desc.worldName + '/about'
@@ -1115,7 +1115,7 @@ class IndexApp {
                             $components: [
                                 {
                                     $type: 'div',
-                                    $text: 'online now: '
+                                    $text: _l.t("online now") + ': '
                                 }
                             ].concat(online)
                         }
@@ -1282,22 +1282,22 @@ class IndexApp {
                         $type: "div",
                         class: "mdc-layout-grid",
                         $components: [
-                            {
-                                $type: "div",
-                                class: "mdc-layout-grid__inner",
-                                $components: [
-                                    {
-                                        $type: "div",
-                                        class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                        $components: [
-                                            {
-                                                $type: "H3",
-                                                $text: headerText
-                                            }
-                                        ]
-                                    }
-                                ]
-                            },
+                            // {
+                            //     $type: "div",
+                            //     class: "mdc-layout-grid__inner",
+                            //     $components: [
+                            //         {
+                            //             $type: "div",
+                            //             class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                            //             $components: [
+                            //                 {
+                            //                     $type: "H3",
+                            //                     $text: headerText
+                            //                 }
+                            //             ]
+                            //         }
+                            //     ]
+                            // },
                             {
                                 $type: "div",
                                 class: "mdc-layout-grid__inner",