aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-03-06 06:55:44 +0300
committerRblSb <msrblsb@gmail.com>2020-03-06 19:03:23 +0300
commitf4546e9f999e2ae26ee83bc706abcd9971317afa (patch)
tree2f60f4af7e9670723a17c9f2add3e5e4ce0489d0
parent0ca7420ad952c0332ab36e37596b0fa53e710325 (diff)
Load only required languages on client
-rw-r--r--README.md2
-rw-r--r--build/server.js2
-rw-r--r--res/client.js53
-rw-r--r--src/Lang.hx12
-rw-r--r--src/client/players/Youtube.hx1
-rw-r--r--src/server/Main.hx1
6 files changed, 44 insertions, 27 deletions
diff --git a/README.md b/README.md
index 993bd9d..dd37e42 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Based on CyTube layout, but with lightweight implementation and very easy way to
### New features
Even if some original features are not implemented yet, there is some new things:
-- Multi-Language
+- Multi-Language support
- Mobile view with page fullscreen
- Way to play local videos for network users (without NAT loopback feature)
- `/30`, `/-21`, etc to rewind video playback in seconds
diff --git a/build/server.js b/build/server.js
index 1e2a5b5..47380bd 100644
--- a/build/server.js
+++ b/build/server.js
@@ -1695,8 +1695,8 @@ Object.defineProperty(js__$Boot_HaxeError.prototype,"message",{ get : function()
return String(this.val);
}});
js_Boot.__toStr = ({ }).toString;
-Lang.ids = ["en","ru"];
Lang.langs = new haxe_ds_StringMap();
+Lang.ids = ["en","ru"];
server_HttpServer.mimeTypes = (function($this) {
var $r;
var _g = new haxe_ds_StringMap();
diff --git a/res/client.js b/res/client.js
index a500324..721babb 100644
--- a/res/client.js
+++ b/res/client.js
@@ -145,37 +145,48 @@ Lang.request = function(path,callback) {
http.request();
};
Lang.init = function(folderPath,callback) {
- var _this = Lang.langs;
- _this.h = { };
- _this.rh = null;
+ var _this = Lang.ids;
+ var _g = [];
+ var _g1 = 0;
+ while(_g1 < _this.length) {
+ var v = _this[_g1];
+ ++_g1;
+ if(v == Lang.lang || v == "en") {
+ _g.push(v);
+ }
+ }
+ Lang.ids = _g;
+ var _this1 = Lang.langs;
+ _this1.h = { };
+ _this1.rh = null;
var count = 0;
- var _g = 0;
- var _g1 = Lang.ids;
- while(_g < _g1.length) {
- var name = [_g1[_g]];
- ++_g;
+ var _g2 = 0;
+ var _g11 = Lang.ids;
+ while(_g2 < _g11.length) {
+ var name = [_g11[_g2]];
+ ++_g2;
Lang.request("" + folderPath + "/" + name[0] + ".json",(function(name1) {
return function(data) {
var data1 = JSON.parse(data);
var lang = new haxe_ds_StringMap();
- var _g2 = 0;
- var _g11 = Reflect.fields(data1);
- while(_g2 < _g11.length) {
- var key = _g11[_g2];
- ++_g2;
- var v = Reflect.field(data1,key);
+ var _g3 = 0;
+ var _g12 = Reflect.fields(data1);
+ while(_g3 < _g12.length) {
+ var key = _g12[_g3];
+ ++_g3;
+ var v1 = Reflect.field(data1,key);
if(__map_reserved[key] != null) {
- lang.setReserved(key,v);
+ lang.setReserved(key,v1);
} else {
- lang.h[key] = v;
+ lang.h[key] = v1;
}
}
var id = haxe_io_Path.withoutExtension(name1[0]);
- var _this1 = Lang.langs;
+ var _this2 = Lang.langs;
if(__map_reserved[id] != null) {
- _this1.setReserved(id,lang);
+ _this2.setReserved(id,lang);
} else {
- _this1.h[id] = lang;
+ _this2.h[id] = lang;
}
count += 1;
if(count == Lang.ids.length && callback != null) {
@@ -1978,7 +1989,7 @@ client_players_Youtube.prototype = {
callback({ duration : tmp});
return;
}, onError : function(e1) {
- haxe_Log.trace("Error " + e1.data,{ fileName : "src/client/players/Youtube.hx", lineNumber : 116, className : "client.players.Youtube", methodName : "getRemoteDataFallback"});
+ haxe_Log.trace("Error " + e1.data,{ fileName : "src/client/players/Youtube.hx", lineNumber : 117, className : "client.players.Youtube", methodName : "getRemoteDataFallback"});
if(_gthis.playerEl.contains(video)) {
_gthis.playerEl.removeChild(video);
}
@@ -2681,8 +2692,8 @@ Object.defineProperty(js__$Boot_HaxeError.prototype,"message",{ get : function()
return String(this.val);
}});
js_Boot.__toStr = ({ }).toString;
-Lang.ids = ["en","ru"];
Lang.langs = new haxe_ds_StringMap();
+Lang.ids = ["en","ru"];
Lang.lang = HxOverrides.substr(window.navigator.language,0,2).toLowerCase();
client_Buttons.personalHistory = [];
client_Buttons.personalHistoryId = -1;
diff --git a/src/Lang.hx b/src/Lang.hx
index 8632812..7b7642d 100644
--- a/src/Lang.hx
+++ b/src/Lang.hx
@@ -7,13 +7,17 @@ import sys.io.File;
#else
import haxe.Http;
#end
+using Lambda;
private typedef LangMap = Map<String, String>;
class Lang {
- static final ids = ["en", "ru"];
static final langs:Map<String, LangMap> = [];
+ static var ids = ["en", "ru"];
+ #if (js && !nodejs)
+ static var lang = js.Browser.navigator.language.substr(0, 2).toLowerCase();
+ #end
static function request(path:String, callback:(data:String)->Void):Void {
#if (sys || nodejs)
@@ -26,6 +30,10 @@ class Lang {
}
public static function init(folderPath:String, ?callback:()->Void):Void {
+ #if (js && !nodejs)
+ // Filter unused languages
+ ids = ids.filter(id -> id == lang || id == "en");
+ #end
langs.clear();
var count = 0;
for (name in ids) {
@@ -50,8 +58,6 @@ class Lang {
return text == null ? key : text;
}
#else
- static var lang = js.Browser.navigator.language.substr(0, 2).toLowerCase();
-
public static function get(key:String):String {
if (langs[lang] == null) lang = "en";
final text = langs[lang][key];
diff --git a/src/client/players/Youtube.hx b/src/client/players/Youtube.hx
index 4307514..15eb014 100644
--- a/src/client/players/Youtube.hx
+++ b/src/client/players/Youtube.hx
@@ -80,6 +80,7 @@ class Youtube implements IPlayer {
}
final title:String = item.snippet.title;
final duration:String = item.contentDetails.duration;
+ // TODO duration is PT0S for streams
callback({
duration: convertTime(duration),
title: title
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 5cac674..e9dd816 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -432,7 +432,6 @@ class Main {
case Rewind:
if (!checkPermission(client, RewindPerm)) return;
if (videoList.length == 0) return;
- // TODO permission
data.rewind.time += videoTimer.getTime();
if (data.rewind.time < 0) data.rewind.time = 0;
videoTimer.setTime(data.rewind.time);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage