Browse Source

add ability to choose language

Added ability to choose language. Default = auto.
master
Hedgehog 11 years ago
parent
commit
5ce24c22e2
  1. 8
      css/style.css
  2. 9
      js/calm.js
  3. 34
      js/interface_localization.js
  4. 50
      options.html

8
css/style.css

@ -1394,13 +1394,13 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
/************************************* /*************************************
**************************** LOGIN PAGE **************************** LOGIN PAGE
**************************************/ **************************************/
.login .module, .sounds .module { .login .module, .sounds .module, .keys .module, .language .module {
padding: 20px; padding: 20px;
width: 500px; width: 500px;
margin: 10px auto; margin: 10px auto;
border: 5px solid #c7cdda; border: 5px solid #c7cdda;
} }
.login .module p, .sounds .module p { .login .module p, .sounds .module p, .keys .module p, .language .module p {
font: 14px "Open Sans", sans-serif; font: 14px "Open Sans", sans-serif;
margin-bottom: 5px; margin-bottom: 5px;
@ -1417,7 +1417,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
background: #fff; background: #fff;
transition: background-color 100ms linear; transition: background-color 100ms linear;
} }
.login .module select.local-usernames, .sndOpt, #keysOpt select{ .login .module select.local-usernames, .sndOpt, #keysOpt select, #choseLanguage select{
height: 30px; height: 30px;
font: 13px/24px "Open sans"; font: 13px/24px "Open sans";
text-align: center; text-align: center;
@ -1889,7 +1889,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
margin-right: -163px; margin-right: -163px;
font: 12px "Open Sans", sans-serif; font: 12px "Open Sans", sans-serif;
} }
#notifyForm p { #notifyForm p, #choseLanguage p, #keysOpt p {
margin-top: 15px; margin-top: 15px;
} }
/* Following page */ /* Following page */

9
js/calm.js

@ -181,10 +181,19 @@ function replaceEmoji() {
}) })
} }
function setLang() {
$('#language').val(localStorage['locLang'] || 'auto')
$('#language').on('change', function(){
localStorage['locLang'] = $(this).val();
})
}
function InitOptions () { function InitOptions () {
soundNotifOptions(); soundNotifOptions();
volumeControl(); volumeControl();
keysSend(); keysSend();
setLang();
} }
function homeIntInit () { function homeIntInit () {
modalDMIntr (); modalDMIntr ();

34
js/interface_localization.js

@ -4,23 +4,27 @@
// uses Polyglot.js ( https://github.com/airbnb/polyglot.js ) to translate interface // uses Polyglot.js ( https://github.com/airbnb/polyglot.js ) to translate interface
// translators: add your language code here such as "es" for Spanish, "ru" for Russian // translators: add your language code here such as "es" for Spanish, "ru" for Russian
var knownLanguages = ["en","nl","it","fr","ru","de","zh"]; var knownLanguages = ["en","nl","it","fr","ru","de","zh"], preferredLanguage;
// detect language with JavaScript if(!localStorage['locLang'] || localStorage['locLang'] == 'auto'){
var preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en"; if(!localStorage['locLang']) localStorage['locLang'] = 'auto';
if(knownLanguages.indexOf(preferredLanguage) > -1){ // detect language with JavaScript
// en for en or similar preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en";
preferredLanguage = preferredLanguage; if(knownLanguages.indexOf(preferredLanguage) > -1){
} // en for en or similar
else if(knownLanguages.indexOf(preferredLanguage.split("-")[0]) > -1){ preferredLanguage = preferredLanguage;
// en for en-US or similar }
preferredLanguage = preferredLanguage.split("-")[0]; else if(knownLanguages.indexOf(preferredLanguage.split("-")[0]) > -1){
} // en for en-US or similar
else{ preferredLanguage = preferredLanguage.split("-")[0];
// did not find match }
preferredLanguage = "en"; else{
// did not find match
preferredLanguage = "en";
}
}else{
preferredLanguage = localStorage['locLang'];
} }
// set up Polyglot // set up Polyglot
polyglot = new Polyglot(); polyglot = new Polyglot();
var wordset = {}; var wordset = {};

50
options.html

@ -48,6 +48,28 @@
<div class="wrapper"> <div class="wrapper">
<div class="language">
<div class="module">
<p> Language </p>
<div>
<form action="" id="choseLanguage">
<p>Use language</p>
<select name="" id="language">
<option value="auto">Auto</option>
<option value="en">English</option>
<option value="ru">Russian</option>
<option value="zh">Chinese</option>
<option value="de">German</option>
<option value="fr">French</option>
<option value="it">Italian</option>
<option value="nl">Dutch</option>
</select>
</form>
</div>
</div>
</div>
<div class="sounds"> <div class="sounds">
<div class="module"> <div class="module">
@ -74,24 +96,26 @@
</select> </select>
<input type="range" name="playerVol" id="playerVol" min="0" max="1" step="0.01"><span class="volValue">0</span> <input type="range" name="playerVol" id="playerVol" min="0" max="1" step="0.01"><span class="volValue">0</span>
</form> </form>
<audio id="player"></audio> <audio id="player"></audio>
</div> </div>
</div> </div>
</div>
<div class="keys"> <div class="keys">
<div class="module">
<div class="module"> <p> Keys </p>
<p> Keys </p> <div>
<div> <form action="" id="keysOpt">
<form action="" id="keysOpt"> <p>Send key</p>
<p>Send key</p> <select name="" id="keysSend">
<select name="" id="keysSend"> <option value="1">Enter</option>
<option value="1">Enter</option> <option value="2">Ctrl/Cmd+Enter</option>
<option value="2">Ctrl/Cmd+Enter</option> </select>
</select> </form>
</form> </div>
</div> </div>
</div>
</div>
</body> </body>
</html> </html>

Loading…
Cancel
Save