Fix language selection in sandboxed iframes
This commit is contained in:
parent
0a656ca8d6
commit
1131ef0172
@ -15,6 +15,7 @@ var map = {
|
|||||||
var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
|
var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
|
||||||
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
|
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
|
||||||
var getLanguage = function () {
|
var getLanguage = function () {
|
||||||
|
if (window.cryptpadLanguage) { return window.cryptpadLanguage; }
|
||||||
if (getStoredLanguage()) { return getStoredLanguage(); }
|
if (getStoredLanguage()) { return getStoredLanguage(); }
|
||||||
var l = getBrowserLanguage() || '';
|
var l = getBrowserLanguage() || '';
|
||||||
if (Object.keys(map).indexOf(l) !== -1) {
|
if (Object.keys(map).indexOf(l) !== -1) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html class="cp-app-noscroll">
|
<html class="cp-app-noscroll">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||||
<script async data-bootload="/code/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
<script async data-bootload="/code/inner.js" data-main="/common/sframe-boot.js?ver=1.5" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||||
<style>
|
<style>
|
||||||
.loading-hidden { display: none; }
|
.loading-hidden { display: none; }
|
||||||
#editor1 { display: none; }
|
#editor1 { display: none; }
|
||||||
|
|||||||
@ -184,6 +184,9 @@ define([
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
common.getLanguage = function () {
|
||||||
|
return Messages._languageUsed;
|
||||||
|
};
|
||||||
common.getUserlist = function () {
|
common.getUserlist = function () {
|
||||||
if (store) {
|
if (store) {
|
||||||
if (store.getProxy() && store.getProxy().info) {
|
if (store.getProxy() && store.getProxy().info) {
|
||||||
|
|||||||
@ -77,5 +77,19 @@ define([], function () {
|
|||||||
Cryptpad.feedback('Migrate-2', true);
|
Cryptpad.feedback('Migrate-2', true);
|
||||||
userObject.version = version = 2;
|
userObject.version = version = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Migration 3: language from localStorage to settings
|
||||||
|
var migrateLanguage = function () {
|
||||||
|
if (!localStorage.CRYPTPAD_LANG) { return; }
|
||||||
|
var l = localStorage.CRYPTPAD_LANG;
|
||||||
|
userObject.settings.language = l;
|
||||||
|
};
|
||||||
|
if (version < 3) {
|
||||||
|
migrateLanguage();
|
||||||
|
Cryptpad.feedback('Migrate-3', true);
|
||||||
|
userObject.version = version = 3;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,6 +42,7 @@ var afterLoaded = function (req) {
|
|||||||
updated: updated,
|
updated: updated,
|
||||||
cache: data.cache
|
cache: data.cache
|
||||||
};
|
};
|
||||||
|
window.cryptpadLanguage = data.language;
|
||||||
require(['/common/sframe-boot2.js'], function () { });
|
require(['/common/sframe-boot2.js'], function () { });
|
||||||
};
|
};
|
||||||
window.addEventListener('message', onReply);
|
window.addEventListener('message', onReply);
|
||||||
|
|||||||
@ -51,7 +51,7 @@ define([
|
|||||||
|
|
||||||
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
||||||
sframeChan = sfc;
|
sframeChan = sfc;
|
||||||
}), false, { cache: cache });
|
}), false, { cache: cache, language: Cryptpad.getLanguage() });
|
||||||
Cryptpad.ready(waitFor());
|
Cryptpad.ready(waitFor());
|
||||||
}));
|
}));
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html class="cp-app-noscroll">
|
<html class="cp-app-noscroll">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||||
<script async data-bootload="/file/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
<script async data-bootload="/file/inner.js" data-main="/common/sframe-boot.js?ver=1.5" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||||
<style>
|
<style>
|
||||||
.loading-hidden { display: none; }
|
.loading-hidden { display: none; }
|
||||||
#editor1 { display: none; }
|
#editor1 { display: none; }
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html style="height: 100%; background: transparent;">
|
<html style="height: 100%; background: transparent;">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||||
<script async data-bootload="/filepicker/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
<script async data-bootload="/filepicker/inner.js" data-main="/common/sframe-boot.js?ver=1.5" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||||
<style>
|
<style>
|
||||||
.loading-hidden { display: none; }
|
.loading-hidden { display: none; }
|
||||||
body #cp-loading {
|
body #cp-loading {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html class="cp-app-noscroll">
|
<html class="cp-app-noscroll">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||||
<script async data-bootload="/pad/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
<script async data-bootload="/pad/inner.js" data-main="/common/sframe-boot.js?ver=1.5" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="cp-app-pad">
|
<body class="cp-app-pad">
|
||||||
<textarea style="display:none" id="editor1" name="editor1"></textarea>
|
<textarea style="display:none" id="editor1" name="editor1"></textarea>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html class="cp-app-noscroll cp-app-print">
|
<html class="cp-app-noscroll cp-app-print">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||||
<script async data-bootload="/slide/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
<script async data-bootload="/slide/inner.js" data-main="/common/sframe-boot.js?ver=1.5" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||||
<style>
|
<style>
|
||||||
.loading-hidden { display: none; }
|
.loading-hidden { display: none; }
|
||||||
#editor1 { display: none; }
|
#editor1 { display: none; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user