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 {
/************************************* /*************************************
**************************** 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 ();

10
js/interface_localization.js

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

28
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">
@ -77,9 +99,9 @@
<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>
@ -91,7 +113,9 @@
</select> </select>
</form> </form>
</div> </div>
</div>
</div>
</div>
</body> </body>
</html> </html>

Loading…
Cancel
Save