[Libreoffice-commits] online.git: loleaflet/js loleaflet/Makefile.am
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Mar 6 12:24:11 UTC 2019
loleaflet/Makefile.am | 3 ++-
loleaflet/js/global.js | 18 ++++++++++--------
2 files changed, 12 insertions(+), 9 deletions(-)
New commits:
commit 318efba0533487f7fc19f06f6341ca44228e3771
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Mar 6 14:17:53 2019 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Mar 6 14:17:53 2019 +0200
Try to make l10n work again in the iOS app
In real Online, after recent commits localisation of messages in our
JavaScript is handled in the FileServer code. Calls to the _ function
in JavaScript being served are replaced with the translated string. We
can't do that in the mobile apps (without some re-work, and I doubt we
want to spend time on that now, there are more pressing problems). In
real Online, the _ function in global.js thus actually dead code.
But in the mobile apps, we don't have any FileServer, and we do want
the _ function to work as before, and we do want to include the
l10n-all.js file in the bundle.js.
Of course, if profiling eventually indicates that doing that *is* a
problem from performance and/or memory usage point of view, we do need
to re-work this. But for now I just want things to roughly work as
they did in the iOS app.
Change-Id: Ib77020010867e7aabaf68bbb892d150d15708213
diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index 953add0c6..59c01a7ff 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -138,7 +138,6 @@ LANGUAGES = \
if ENABLE_IOSAPP
L10N_IOS_ALL_JS = $(builddir)/dist/l10n-all.js
-L10N_JSON = $(L10N_IOS_ALL_JS)
$(L10N_IOS_ALL_JS) : $(wildcard $(srcdir)/po/ui-*.po) $(shell find $(srcdir)/l10n -name '*.*')
for F in $(wildcard $(srcdir)/po/ui-*.po); do \
@@ -265,6 +264,7 @@ ADMIN_BUNDLE = $(builddir)/dist/admin-bundle.js
endif
build-loleaflet: | \
+ $(L10N_IOS_ALL_JS) \
$(LOLEAFLET_MO_DST) \
$(LOLEAFLET_IMAGES_DST) \
$(JQUERY_LIGHTNESS_DIST_IMAGES) \
@@ -348,6 +348,7 @@ $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_SRC) \
$(srcdir)/js/main.js
@echo "Uglify loleaflet js files..."
NODE_PATH=$(abs_builddir)/node_modules $(NODE) node_modules/uglify-js/bin/uglifyjs \
+ $(L10N_IOS_ALL_JS) \
$(NODE_MODULES_JS) \
$(srcdir)/js/jquery.mCustomScrollbar.js \
$(srcdir)/js/w2ui-1.5.rc1.js \
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index d7cbc3413..bc1e96e05 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -53,9 +53,11 @@
String.locale = 'en';
}
- global._ = function (string) {
- // In the mobile app case we can't use the stuff from l10n-for-node, as that assumes HTTP.
- if (window.ThisIsTheiOSApp) {
+ // In the mobile app case we don't use any "server-side" localisation. For real Online, what
+ // looks like calls to a _ function are in fact replaced by Online's file server with the
+ // translation.
+ if (window.ThisIsTheiOSApp) {
+ global._ = function (string) {
// We use another approach just for iOS for now.
if (window.LOCALIZATIONS.hasOwnProperty(string)) {
// window.postMobileDebug('_(' + string + '): YES: ' + window.LOCALIZATIONS[string]);
@@ -68,13 +70,13 @@
// window.postMobileDebug('_(' + string + '): NO');
return string;
}
- } else if (window.ThisIsAMobileApp) {
- // And bail out without translations on other mobile platforms.
+ }
+ } else if (window.ThisIsAMobileApp) {
+ // Bail out without translations on other mobile platforms for now.
+ global._ = function (string) {
return string;
- } else {
- return string.toLocaleString();
}
- };
+ }
var docParams, wopiParams;
var filePath = global.getParameterByName('file_path');
More information about the Libreoffice-commits
mailing list