Skip to content

Commit

Permalink
Fix Translations (OSX)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Mar 6, 2016
1 parent d171cc3 commit 2b366dc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/hotkeys.html
Expand Up @@ -205,7 +205,11 @@ <h2 class="i18n">Developers</h2>
if (!localStorage.appLang) localStorage.appLang = 'template';
if (['template','English'].indexOf(localStorage.appLang) > -1) newLang = 'template';
else newLang = localStorage.appLang;
translator.changeLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
if (process.platform == 'darwin') {
translator.changeLocal('./locale/' + newLang.split(' ').join('_'));
} else {
translator.changeLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
}
var i18n = translator.i18n;
document.title = i18n(document.title);
</script>
Expand Down
14 changes: 12 additions & 2 deletions src/lib/ui.js
Expand Up @@ -787,7 +787,13 @@ function refreshMainBut() {
}
}

require('fs').readdir(require('path').dirname(process.execPath)+'/src/locale', function(err, files) {
if (process.platform == 'darwin') {
var localePath = './src/locale';
} else {
var localePath = require('path').dirname(process.execPath)+'/src/locale';
}

require('fs').readdir(localePath, function(err, files) {
var langOptions = '<option class="i18n">' + i18n('English') + '</option>';
langOptions += files.map(function(el) {
return el != 'template.js' ? '<option value="' + el.replace('.js', '').split('_').join(' ') + '">' + translator.langName(el.replace('.js', '').split('_').join(' ')) + '</option>' : '';
Expand All @@ -801,7 +807,11 @@ $("#change-lang").on('change', function() {
} else {
localStorage.appLang = $(this).val();
}
translator.changeLocal(require('path').dirname(process.execPath)+'/src/locale/' + localStorage.appLang.split(' ').join('_'));
if (process.platform == 'darwin') {
translator.changeLocal('./locale/' + localStorage.appLang.split(' ').join('_'));
} else {
translator.changeLocal(require('path').dirname(process.execPath)+'/src/locale/' + localStorage.appLang.split(' ').join('_'));
}
setTimeout(function() {
refreshMainBut();
},0);
Expand Down
6 changes: 5 additions & 1 deletion src/mask.html
Expand Up @@ -33,7 +33,11 @@
if (!localStorage.appLang) localStorage.appLang = 'template';
if (['template','English'].indexOf(localStorage.appLang) > -1) newLang = 'template';
else newLang = localStorage.appLang;
translator.setLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
if (process.platform == 'darwin') {
translator.setLocal('./locale/' + newLang.split(' ').join('_'));
} else {
translator.setLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
}
var i18n = translator.i18n;
</script>
<script src="lib/defaults.js"></script>
Expand Down
6 changes: 5 additions & 1 deletion src/updater.html
Expand Up @@ -14,7 +14,11 @@
if (!localStorage.appLang) localStorage.appLang = 'template';
if (['template','English'].indexOf(localStorage.appLang) > -1) newLang = 'template';
else newLang = localStorage.appLang;
translator.setLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
if (process.platform == 'darwin') {
translator.setLocal('./locale/' + newLang.split(' ').join('_'));
} else {
translator.setLocal(require('path').dirname(process.execPath)+'/src/locale/' + newLang.split(' ').join('_'));
}
var i18n = translator.i18n;
document.title = i18n(document.title);
</script>
Expand Down

0 comments on commit 2b366dc

Please sign in to comment.