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. 10
      js/interface_localization.js
  4. 28
      options.html

8
css/style.css

@ -1394,13 +1394,13 @@ input.userMenu-search-field:focus::-ms-input-placeholder { @@ -1394,13 +1394,13 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
/*************************************
**************************** LOGIN PAGE
**************************************/
.login .module, .sounds .module {
.login .module, .sounds .module, .keys .module, .language .module {
padding: 20px;
width: 500px;
margin: 10px auto;
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;
margin-bottom: 5px;
@ -1417,7 +1417,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder { @@ -1417,7 +1417,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
background: #fff;
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;
font: 13px/24px "Open sans";
text-align: center;
@ -1889,7 +1889,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder { @@ -1889,7 +1889,7 @@ input.userMenu-search-field:focus::-ms-input-placeholder {
margin-right: -163px;
font: 12px "Open Sans", sans-serif;
}
#notifyForm p {
#notifyForm p, #choseLanguage p, #keysOpt p {
margin-top: 15px;
}
/* Following page */

9
js/calm.js

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

10
js/interface_localization.js

@ -4,10 +4,12 @@ @@ -4,10 +4,12 @@
// 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
var knownLanguages = ["en","nl","it","fr","ru","de","zh"];
var knownLanguages = ["en","nl","it","fr","ru","de","zh"], preferredLanguage;
if(!localStorage['locLang'] || localStorage['locLang'] == 'auto'){
if(!localStorage['locLang']) localStorage['locLang'] = 'auto';
// detect language with JavaScript
var preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en";
preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en";
if(knownLanguages.indexOf(preferredLanguage) > -1){
// en for en or similar
preferredLanguage = preferredLanguage;
@ -20,7 +22,9 @@ else{ @@ -20,7 +22,9 @@ else{
// did not find match
preferredLanguage = "en";
}
}else{
preferredLanguage = localStorage['locLang'];
}
// set up Polyglot
polyglot = new Polyglot();
var wordset = {};

28
options.html

@ -48,6 +48,28 @@ @@ -48,6 +48,28 @@
<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="module">
@ -77,9 +99,9 @@ @@ -77,9 +99,9 @@
<audio id="player"></audio>
</div>
</div>
</div>
<div class="keys">
<div class="module">
<p> Keys </p>
<div>
@ -91,7 +113,9 @@ @@ -91,7 +113,9 @@
</select>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

Loading…
Cancel
Save