[Libreoffice-commits] online.git: loleaflet/html loleaflet/js loleaflet/Makefile.am

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Mar 6 02:38:42 UTC 2019


 loleaflet/Makefile.am            |   23 ---
 loleaflet/html/loleaflet.html.m4 |    9 -
 loleaflet/js/l10n.js             |  291 ---------------------------------------
 3 files changed, 323 deletions(-)

New commits:
commit c9685387b9fb639ab9d31fa0619cb0beab430e8a
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Feb 10 19:02:56 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Mar 5 22:38:13 2019 -0400

    loleaflet: remove client side L10n
    
    Change-Id: I4bd40e569441c22b902b5bac2cb21705a4565384

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index e220dbd62..31df8f092 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -164,11 +164,6 @@ JQUERY_MINIFIED_DIST_IMAGES = $(patsubst $(JQUERY_MINIFIED_IMAGE_PATH)/%.png,$(b
 LOLEAFLET_IMAGES_SRC = $(shell find $(srcdir)/images -name '*.*')
 LOLEAFLET_IMAGES_DST = $(patsubst $(srcdir)/%,$(builddir)/dist/%,$(LOLEAFLET_IMAGES_SRC))
 
-LOLEAFLET_L10N_SRC = $(shell find $(srcdir)/l10n -name '*.*')
-if !ENABLE_IOSAPP
-LOLEAFLET_L10N_DST =  $(patsubst $(srcdir)/l10n/%,$(builddir)/dist/l10n/%,$(LOLEAFLET_L10N_SRC))
-endif
-
 LOLEAFLET_DRAW_JS_SRC = $(shell find $(srcdir)/plugins/draw-$(DRAW_VERSION)/src -name '*.js')
 LOLEAFLET_DRAW_JS_DST = $(patsubst $(srcdir)/plugins/%.js,$(builddir)/dist/plugins/%.js,$(LOLEAFLET_DRAW_JS_SRC))
 
@@ -256,11 +251,6 @@ NODE_MODULES_JS =\
 	node_modules/vex-js/js/vex.js \
 	node_modules/vex-js/js/vex.dialog.js
 
-if !ENABLE_MOBILEAPP
-NODE_MODULES_JS +=\
-	node_modules/l10n-for-node/l10n.js
-endif
-
 NODE_MODULES_JS_SRC = $(patsubst %.js,$(builddir)/%.js,$(NODE_MODULES_JS))
 NODE_MODULES_JS_DST = $(patsubst %.js,$(builddir)/dist/%.js,$(NODE_MODULES_JS))
 
@@ -345,7 +335,6 @@ $(builddir)/dist/bundle.css: $(LOLEAFLET_CSS_DST)
 $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_DST) \
 	$(LOLEAFLET_PREFIX)/dist/loleaflet-src.js \
 	$(builddir)/dist/global.js \
-	$(builddir)/dist/l10n.js \
 	$(builddir)/dist/w2ui-1.5.rc1.js \
 	$(builddir)/dist/toolbar.js \
 	$(builddir)/dist/main.js
@@ -374,22 +363,15 @@ $(builddir)/dist/global.js: $(srcdir)/js/global.js
 	@echo "Uglify global.js file..."
 	@NODE_PATH=$(abs_builddir)/node_modules $(NODE) node_modules/uglify-js/bin/uglifyjs $< --output $@
 
-$(builddir)/dist/l10n.js: $(srcdir)/js/l10n.js
-	@echo "Uglify l10n.js file..."
-	@NODE_PATH=$(abs_builddir)/node_modules $(NODE) node_modules/uglify-js/bin/uglifyjs $< --output $@
-
 $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_SRC) \
 	$(LOLEAFLET_PREFIX)/dist/loleaflet-src.js \
 	$(builddir)/dist/global.js \
-	$(builddir)/dist/l10n.js \
 	$(srcdir)/js/jquery.mCustomScrollbar.js \
 	$(srcdir)/js/w2ui-1.5.rc1.js \
 	$(srcdir)/js/toolbar.js \
 	$(srcdir)/js/main.js
 	@echo "Uglify loleaflet js files..."
 	NODE_PATH=$(abs_builddir)/node_modules $(NODE) node_modules/uglify-js/bin/uglifyjs \
-		$(srcdir)/js/global.js \
-		$(L10N_IOS_ALL_JS) \
 		$(NODE_MODULES_JS) \
 		$(srcdir)/js/jquery.mCustomScrollbar.js \
 		$(srcdir)/js/w2ui-1.5.rc1.js \
@@ -410,11 +392,6 @@ $(builddir)/dist/loleaflet.html: $(srcdir)/html/loleaflet.html.m4 $(LOLEAFLET_HT
 		-DLOLEAFLET_CSS="$(subst $(SPACE),$(COMMA),$(LOLEAFLET_CSS_M4))" \
 		-DBUNDLE_CSS="$(abs_builddir)/dist/bundle.css" \
 		-DGLOBAL_JS="$(abs_builddir)/dist/global.js" \
-		-DL10N_JS="$(abs_builddir)/dist/l10n.js" \
-		-DLOCALIZATION_JSON="$(abs_builddir)/dist/l10n/localizations.json" \
-		-DLOCORE_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/locore-localizations.json" \
-		-DHELP_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/help-localizations.json" \
-		-DUNO_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/uno-localizations.json" \
 		-DLOLEAFLET_JS="$(subst $(SPACE),$(COMMA),$(NODE_MODULES_JS) \
 		$(call LOLEAFLET_JS,$(srcdir)/build/build.js) \
 		$(patsubst %.js,plugins/draw-$(DRAW_VERSION)/%.js,$(call LOLEAFLET_JS,$(srcdir)/plugins/draw-$(DRAW_VERSION)/build/build.js)) \
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 7083857e3..270db259e 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -30,10 +30,6 @@ ifelse(MOBILEAPP,[],
     }
   };
   window.addEventListener('message', PostMessageReadyListener, false);
-  window.__globalL10n = syscmd([cat ]LOCALIZATION_JSON);
-  window.__locoreL10n = syscmd([cat ]LOCORE_LOCALIZATION_JSON);
-  window.__helpL10n = syscmd([cat ]HELP_LOCALIZATION_JSON);
-  window.__unoL10n = syscmd([cat ]UNO_LOCALIZATION_JSON);
 ])dnl
 
 var Base64ToArrayBuffer = function(base64Str) {
@@ -165,11 +161,6 @@ ifelse(MOBILEAPP,[true],
       window.idleTimeoutSecs = <%IDLE_TIMEOUT_SECS%>;
       window.tileSize = 256;])
 syscmd([cat ]GLOBAL_JS)dnl
-syscmd([cat ]L10N_JS)dnl
-      delete window.__globalL10n;
-      delete window.__locoreL10n;
-      delete window.__helpL10n;
-      delete window.__unoL10n;
     </script>
   <script defer>
 
diff --git a/loleaflet/js/l10n.js b/loleaflet/js/l10n.js
deleted file mode 100644
index d9ca75506..000000000
--- a/loleaflet/js/l10n.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * l10n.js
- * 2016-05-17
- *
- * By Eli Grey, http://eligrey.com
- * Licensed under the MIT License
- *   See https://github.com/eligrey/l10n.js/blob/master/LICENSE.md
- */
-
-/*global XMLHttpRequest, setTimeout, document, navigator, ActiveXObject*/
-
-/*! @source http://purl.eligrey.com/github/l10n.js/blob/master/l10n.js*/
-
-(function () {
-"use strict";
-
-var
-  undef_type = "undefined"
-, string_type = "string"
-, nav = {}
-, lang = {}
-, String_ctr = String
-, has_own_prop = Object.prototype.hasOwnProperty
-, load_queues = {}
-, localizations = {}
-, FALSE = !1
-, TRUE = !0
-, browserless = FALSE
-// the official format is application/vnd.oftn.l10n+json, though l10n.js will also
-// accept application/x-l10n+json and application/l10n+json
-, l10n_js_media_type = /^\s*application\/(?:vnd\.oftn\.|x-)?l10n\+json\s*(?:$|;)/i
-, XHR
-
-// property minification aids
-, $locale = "locale"
-, $default_locale = "defaultLocale"
-, $to_locale_string = "toLocaleString"
-, $to_lowercase = "toLowerCase"
-
-, array_index_of = Array.prototype.indexOf || function (item) {
-	var
-	  len = this.length
-	, i   = 0
-	;
-
-	for (; i < len; i++) {
-		if (i in this && this[i] === item) {
-			return i;
-		}
-	}
-
-	return -1;
-}
-, request_JSON = function (uri) {
-    if(browserless)
-        return loadFromDisk(uri);
-
-	var req  = new XHR(),
-		data = {};
-
-	// sadly, this has to be blocking to allow for a graceful degrading API
-	req.open("GET", uri, FALSE);
-	req.send(null);
-
-	// Status codes can be inconsistent across browsers so we simply try to parse
-	// the response text and catch any errors. This deals with failed requests as
-	// well as malformed json files.
-	try {
-		data = JSON.parse(req.responseText);
-	} catch(e) {
-		// warn about error without stopping execution
-		setTimeout(function () {
-			// Error messages are not localized as not to cause an infinite loop
-			var l10n_err = new Error("Unable to load localization data: " + uri);
-			l10n_err.name = "Localization Error";
-			throw l10n_err;
-		}, 0);
-	}
-
-	return data;
-}
-, load = String_ctr[$to_locale_string] = function (data) {
-	// don't handle function.toLocaleString(indentationAmount:Number)
-	if (arguments.length > 0 && typeof data !== "number") {
-		if (typeof data === string_type) {
-			load(request_JSON(data));
-		} else if (data === FALSE) {
-			// reset all localizations
-			localizations = {};
-		} else {
-			// Extend current localizations instead of completely overwriting them
-			var locale, localization, message;
-			for (locale in data) {
-				if (has_own_prop.call(data, locale)) {
-					localization = data[locale];
-					locale = locale[$to_lowercase]();
-
-					if (!(locale in localizations) || localization === FALSE) {
-						// reset locale if not existing or reset flag is specified
-						localizations[locale] = {};
-					}
-
-					if (localization === FALSE) {
-						continue;
-					}
-
-					// URL specified
-					if (typeof localization === string_type) {
-						if (String_ctr[$locale][$to_lowercase]().indexOf(locale) === 0) {
-							localization = request_JSON(localization);
-						} else {
-							// queue loading locale if not needed
-							if (!(locale in load_queues)) {
-								load_queues[locale] = [];
-							}
-							load_queues[locale].push(localization);
-							continue;
-						}
-					}
-
-					for (message in localization) {
-						if (has_own_prop.call(localization, message)) {
-							localizations[locale][message] = localization[message];
-						}
-					}
-				}
-			}
-		}
-	}
-	// Return what function.toLocaleString() normally returns
-	return Function.prototype[$to_locale_string].apply(String_ctr, arguments);
-}
-, loadFromDisk = String_ctr[$to_locale_string] = function (uri) {
-        const fs = require('fs');
-        var read = fs.readFileSync(uri, 'utf8');
-        return JSON.parse(read);
-}
-, process_load_queue = function (locale) {
-	var
-	  queue = load_queues[locale]
-	, i = 0
-	, len = queue.length
-	, localization
-	;
-
-	for (; i < len; i++) {
-		localization = {};
-		localization[locale] = request_JSON(queue[i]);
-		load(localization);
-	}
-
-	delete load_queues[locale];
-}
-, use_default
-, localize = String_ctr.prototype[$to_locale_string] = function () {
-	var
-	  using_default = use_default
-	, current_locale = String_ctr[using_default ? $default_locale : $locale]
-	, parts = current_locale[$to_lowercase]().split("-")
-	, i = parts.length
-	, this_val = this.valueOf()
-	, locale
-	;
-
-	use_default = FALSE;
-
-	// Iterate through locales starting at most-specific until a localization is found
-	do {
-		locale = parts.slice(0, i).join("-");
-		// load locale if not loaded
-		if (locale in load_queues) {
-			process_load_queue(locale);
-		}
-		if (locale in localizations && this_val in localizations[locale]) {
-			return localizations[locale][this_val];
-		}
-	}
-	while (i--);
-
-	if (!using_default && String_ctr[$default_locale]) {
-		use_default = TRUE;
-		return localize.call(this_val);
-	}
-
-	return this_val;
-}
-;
-
-try
-{
-    nav = self.navigator;
-    lang = self.getParameterByName('lang');
-}
-catch(selfNotFoundException)
-{
-   if(global.nav)
-   {
-        nav = global.nav;
-   }
-   else
-   {
-       var nodeError = "Problem setting nav in L10N. You are most likely running in a non-browser environment like Node." +
-        "If this is the case, you can resolve this error by setting global.nav to an object which contains a \"language\"  field. ";
-       throw new Error(nodeError);
-   }
-   browserless = TRUE;
-}
-
-if (!browserless && typeof XMLHttpRequest === undef_type && typeof ActiveXObject !== undef_type) {
-	var AXO = ActiveXObject;
-
-	XHR = function () {
-		try {
-			return new AXO("Msxml2.XMLHTTP.6.0");
-		} catch (xhrEx1) {}
-		try {
-			return new AXO("Msxml2.XMLHTTP.3.0");
-		} catch (xhrEx2) {}
-		try {
-			return new AXO("Msxml2.XMLHTTP");
-		} catch (xhrEx3) {}
-
-		throw new Error("XMLHttpRequest not supported by this browser.");
-	};
-} else {
-    try
-    {
-        XHR = XMLHttpRequest;
-    }
-    catch(xhrEx4)
-    {
-        if(global.XMLHttpRequest) {
-            XHR = global.XMLHttpRequest;
-        }
-        else {
-           var nodeError = "Problem setting XHR in L10N. You are most likely running in a non-browser environment like Node." +
-            "If this is the case, you can resolve this error by setting global.XMLHttpRequest to a function which produces XMLHttpRequests. " +
-            "\nTip: if you are using node, you might want to use the XHR2 package (usage: global.XMLHttpRequest = require('xhr2')";
-            throw new Error(nodeError);
-        }
-    }
-}
-
-String_ctr[$default_locale] = String_ctr[$default_locale] || "";
-String_ctr[$locale] = nav && lang && (lang) || "en";
-
-if (!browserless || typeof document !== undef_type) {
-	var
-	  elts = document.getElementsByTagName("link")
-	, i = elts.length
-	, localization
-	;
-
-	while (i--) {
-		var
-		  elt = elts[i]
-		, rel = (elt.getAttribute("rel") || "")[$to_lowercase]().split(/\s+/)
-		;
-
-		if (l10n_js_media_type.test(elt.type)) {
-			if (array_index_of.call(rel, "localizations") !== -1) {
-				// multiple localizations
-				load(elt.getAttribute("href"));
-			} else if (array_index_of.call(rel, "localization") !== -1) {
-				// single localization
-				localization = {};
-				localization[(elt.getAttribute("hreflang") || "")[$to_lowercase]()] =
-					elt.getAttribute("href");
-				load(localization);
-			}
-		}
-	}
-
-	load(self.__globalL10n);
-	load(self.__locoreL10n);
-	load(self.__helpL10n);
-	load(self.__unoL10n);
-}
-else
-{
-    if(global.l10NLocalFilePath) {
-        load(global.l10NLocalFilePath);
-    }
-    else {
-        var nodeError = "Problem loading localization file. You are most likely running in a non-browser environment like Node." +
-            "If this is the case, you can resolve this error by setting global.l10NLocalFilePath to the path of your localization file. ";
-        throw new Error(nodeError);
-    }
-}
-
-}());


More information about the Libreoffice-commits mailing list