12345678910111213141516171819 |
- //使用自执行函数,避免污染同名变量
- (function () {
- const languageList = ['zh-CN']
- const LOCAL_LANGUAGE = navigator.language;
- const getLanguage = (language = localStorage.handPyLanguage || LOCAL_LANGUAGE) => {
- if (!languageList.includes(language) || !languageList.includes(language.split("-")[0]))
- language = 'zh-CN';
- const val = location.search.match(new RegExp('[?&]lang=([^&]+)'));
- language = val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : '';
- if (['en', 'zh-hant', 'zh-hans'].indexOf(language) < 0) { language = 'zh-hant'; }
- localStorage.handPyLanguage = language;
- document.write('<script src="blockly/msg/' + language + '/blockly_messages.js"><\/script>');
- document.write('<script src="blockly/msg/' + language + '/blocks_messages.js"><\/script>');
- document.write('<script src="blockly/msg/' + language + '/microbit_messages.js"><\/script>');
- document.write('<script src="blockly/msg/' + language + '/other_messages.js"><\/script>');
- document.write('<script src="blockly/msg/js/' + language + '.js"><\/script>');
- }
- getLanguage()
- })()
|