Skip to content

Commit

Permalink
多语言动态切换。
Browse files Browse the repository at this point in the history
  • Loading branch information
tengge1 committed Jan 28, 2019
1 parent eab0358 commit b1f9ff8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 87 deletions.
84 changes: 0 additions & 84 deletions ShadowEditor.Web/index-en.html

This file was deleted.

29 changes: 26 additions & 3 deletions ShadowEditor.Web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,43 @@

<!-- Shadow Editor -->
<script src="dist/ShadowEditor.js"></script>
<script src="lang/zh-CN.js"></script>
<script>
var container = null;
var app = null;

var start = function () {
var lang = window.localStorage.getItem('lang') || 'zh-CN';

var loadJs = url => {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;

document.body.appendChild(script);

return new Promise(resolve => {
script.onload = () => {
resolve();
}
});
};

var start = () => {
container = document.getElementById('container');
app = new Shadow.Application(container, {
server: location.origin
});
app.start();
};

window.onload = start;
window.onload = () => {
if (lang === 'zh-CN') {
loadJs('lang/zh-CN.js').then(() => {
start();
});
} else {
start();
}
};
</script>
</body>

Expand Down

0 comments on commit b1f9ff8

Please sign in to comment.