Merge pull request #892 from McGiverGim/bf-language_user_selectable
Language user selectable in app10.3.x-maintenance
commit
fd0afd1456
|
@ -1,7 +0,0 @@
|
||||||
[Desktop Entry]
|
|
||||||
Name=Betaflight Configurator (English)
|
|
||||||
Comment=Crossplatform configuration tool for the Betaflight flight control system
|
|
||||||
Exec=bash -c "LANGUAGE=en /opt/betaflight/betaflight-configurator/betaflight-configurator"
|
|
||||||
Icon=/opt/betaflight/betaflight-configurator/icon/bf_icon_english_128.png
|
|
||||||
Terminal=false
|
|
||||||
Type=Application
|
|
|
@ -119,6 +119,9 @@ Section
|
||||||
${EndIf}
|
${EndIf}
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
# the english shortcut is not installed in actual versions, remove the deletion in a future release
|
||||||
|
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME} (English).lnk"
|
||||||
|
|
||||||
# if the registry entries did not exist, we ignore the errors
|
# if the registry entries did not exist, we ignore the errors
|
||||||
ClearErrors
|
ClearErrors
|
||||||
|
|
||||||
|
@ -140,7 +143,6 @@ Section
|
||||||
# create shortcuts in the start menu and on the desktop
|
# create shortcuts in the start menu and on the desktop
|
||||||
CreateDirectory "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}"
|
CreateDirectory "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}"
|
||||||
CreateShortCut "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_EXECUTABLE}"
|
CreateShortCut "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_EXECUTABLE}"
|
||||||
CreateShortCut "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME} (English).lnk" "$INSTDIR\${FILE_NAME_EXECUTABLE}" "--lang=en"
|
|
||||||
CreateShortCut "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_UNINSTALLER}"
|
CreateShortCut "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_UNINSTALLER}"
|
||||||
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_EXECUTABLE}"
|
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${FILE_NAME_EXECUTABLE}"
|
||||||
|
|
||||||
|
@ -184,6 +186,7 @@ Section "Uninstall"
|
||||||
RMDir "$INSTDIR"
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
# delete the shortcuts
|
# delete the shortcuts
|
||||||
|
# the english shortcut is not installed in actual versions, remove the deletion in a future release
|
||||||
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME}.lnk"
|
||||||
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME} (English).lnk"
|
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\${APP_NAME} (English).lnk"
|
||||||
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\Uninstall ${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\${GROUP_NAME}\${FOLDER_NAME}\Uninstall ${APP_NAME}.lnk"
|
||||||
|
|
|
@ -482,8 +482,8 @@ function release_deb(arch) {
|
||||||
architecture: debArch,
|
architecture: debArch,
|
||||||
maintainer: pkg.author,
|
maintainer: pkg.author,
|
||||||
description: pkg.description,
|
description: pkg.description,
|
||||||
postinst: ['xdg-desktop-menu install /opt/betaflight/betaflight-configurator/betaflight-configurator.desktop /opt/betaflight/betaflight-configurator/betaflight-configurator-english.desktop'],
|
postinst: ['xdg-desktop-menu install /opt/betaflight/betaflight-configurator/betaflight-configurator.desktop'],
|
||||||
prerm: ['xdg-desktop-menu uninstall betaflight-configurator.desktop betaflight-configurator-english.desktop'],
|
prerm: ['xdg-desktop-menu uninstall betaflight-configurator.desktop'],
|
||||||
depends: 'libgconf-2-4',
|
depends: 'libgconf-2-4',
|
||||||
changelog: [],
|
changelog: [],
|
||||||
_target: 'opt/betaflight/betaflight-configurator',
|
_target: 'opt/betaflight/betaflight-configurator',
|
||||||
|
|
|
@ -48,6 +48,31 @@
|
||||||
"permanentExpertMode": {
|
"permanentExpertMode": {
|
||||||
"message": "Permanently enable Expert Mode"
|
"message": "Permanently enable Expert Mode"
|
||||||
},
|
},
|
||||||
|
"userLanguageSelect": {
|
||||||
|
"message": "Language (need to restart the application for the changes to take effect)"
|
||||||
|
},
|
||||||
|
"language_default": {
|
||||||
|
"message": "Default"
|
||||||
|
},
|
||||||
|
"language_ca": {
|
||||||
|
"message": "Catalan"
|
||||||
|
},
|
||||||
|
"language_de": {
|
||||||
|
"message": "German"
|
||||||
|
},
|
||||||
|
"language_en": {
|
||||||
|
"message": "English"
|
||||||
|
},
|
||||||
|
"language_es": {
|
||||||
|
"message": "Spanish"
|
||||||
|
},
|
||||||
|
"language_fr": {
|
||||||
|
"message": "French"
|
||||||
|
},
|
||||||
|
"language_ko": {
|
||||||
|
"message": "Korean"
|
||||||
|
},
|
||||||
|
|
||||||
"sensorStatusGyro": {
|
"sensorStatusGyro": {
|
||||||
"message": "Gyroscope"
|
"message": "Gyroscope"
|
||||||
},
|
},
|
||||||
|
|
|
@ -406,6 +406,21 @@ input[type="number"]::-webkit-inner-spin-button {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#options-window .separator {
|
||||||
|
padding-bottom: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
}
|
||||||
|
#options-window .dropdown {
|
||||||
|
float: left;
|
||||||
|
width: auto;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#options-window select {
|
||||||
|
margin-right: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
/* Log setup*/
|
/* Log setup*/
|
||||||
#log {
|
#log {
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
|
|
|
@ -6,17 +6,19 @@
|
||||||
|
|
||||||
var i18n = {}
|
var i18n = {}
|
||||||
|
|
||||||
|
const languagesAvailables = ['ca', 'de', 'en', 'es', 'fr', 'ko'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions that depend on the i18n framework
|
* Functions that depend on the i18n framework
|
||||||
*/
|
*/
|
||||||
i18n.init = function(cb) {
|
i18n.init = function(cb) {
|
||||||
|
|
||||||
var defaultLocale = window.navigator.userLanguage || window.navigator.language;
|
getStoredUserLocale(function(userLanguage){
|
||||||
|
|
||||||
i18next
|
i18next
|
||||||
.use(i18nextXHRBackend)
|
.use(i18nextXHRBackend)
|
||||||
.init({
|
.init({
|
||||||
lng: defaultLocale,
|
lng: userLanguage,
|
||||||
getAsync: false,
|
getAsync: false,
|
||||||
debug: true,
|
debug: true,
|
||||||
ns: ['messages'],
|
ns: ['messages'],
|
||||||
|
@ -33,6 +35,7 @@ i18n.init = function(cb) {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
i18n.getMessage = function(messageID, parameters) {
|
i18n.getMessage = function(messageID, parameters) {
|
||||||
|
@ -45,8 +48,10 @@ i18n.getMessage = function(messageID, parameters) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return translatedString;
|
return translatedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
i18n.getLanguagesAvailables = function() {
|
||||||
|
return languagesAvailables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,3 +98,28 @@ i18n.localizePage = function() {
|
||||||
|
|
||||||
return localized;
|
return localized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads the chrome config, if DEFAULT or there is no config stored,
|
||||||
|
* returns the current locale to the callback
|
||||||
|
*/
|
||||||
|
function getStoredUserLocale(cb) {
|
||||||
|
chrome.storage.local.get('userLanguageSelect', function (result) {
|
||||||
|
var userLanguage = 'DEFAULT';
|
||||||
|
if (result.userLanguageSelect) {
|
||||||
|
userLanguage = result.userLanguageSelect
|
||||||
|
}
|
||||||
|
|
||||||
|
userLanguage = getValidLocale(userLanguage);
|
||||||
|
|
||||||
|
cb(userLanguage);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValidLocale(userLocale) {
|
||||||
|
|
||||||
|
if (userLocale == 'DEFAULT') {
|
||||||
|
userLocale = window.navigator.userLanguage || window.navigator.language;
|
||||||
|
}
|
||||||
|
return userLocale;
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
//Process to execute to real start the app
|
//Process to execute to real start the app
|
||||||
function startProcess() {
|
function startProcess() {
|
||||||
|
|
||||||
// translate to user-selected language
|
// translate to user-selected language
|
||||||
i18n.localizePage();
|
i18n.localizePage();
|
||||||
|
|
||||||
|
@ -232,6 +233,29 @@ function startProcess() {
|
||||||
$('div.checkForConfiguratorUnstableVersions').hide();
|
$('div.checkForConfiguratorUnstableVersions').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chrome.storage.local.get('userLanguageSelect', function (result) {
|
||||||
|
|
||||||
|
var userLanguage_e = $('div.userLanguage select');
|
||||||
|
var languagesAvailables = i18n.getLanguagesAvailables();
|
||||||
|
userLanguage_e.append('<option value="DEFAULT">' + i18n.getMessage('language_default') + '</option>');
|
||||||
|
userLanguage_e.append('<option disabled>------</option>');
|
||||||
|
languagesAvailables.forEach(function(element) {
|
||||||
|
var languageName = i18n.getMessage('language_' + element);
|
||||||
|
userLanguage_e.append('<option value="' + element + '">' + languageName + '</option>');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.userLanguageSelect) {
|
||||||
|
userLanguage_e.val(result.userLanguageSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
userLanguage_e.change(function () {
|
||||||
|
var languageSelected = $(this).val();
|
||||||
|
|
||||||
|
// Select the new language, a restart is required
|
||||||
|
chrome.storage.local.set({'userLanguageSelect': languageSelected});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function close_and_cleanup(e) {
|
function close_and_cleanup(e) {
|
||||||
if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) {
|
if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) {
|
||||||
$(document).unbind('click keyup', close_and_cleanup);
|
$(document).unbind('click keyup', close_and_cleanup);
|
||||||
|
@ -364,7 +388,7 @@ function startProcess() {
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function checkForConfiguratorUpdates() {
|
function checkForConfiguratorUpdates() {
|
||||||
var releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases');
|
var releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases');
|
||||||
|
@ -602,7 +626,6 @@ function getManifestVersion(manifest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNewWindowsInExternalBrowser() {
|
function openNewWindowsInExternalBrowser() {
|
||||||
// Open new windows in external browser
|
|
||||||
try {
|
try {
|
||||||
var gui = require('nw.gui');
|
var gui = require('nw.gui');
|
||||||
|
|
||||||
|
@ -615,6 +638,6 @@ function openNewWindowsInExternalBrowser() {
|
||||||
policy.ignore();
|
policy.ignore();
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn("require does not exist, maybe inside chrome");
|
console.log("require does not exist, maybe inside chrome");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,3 +4,14 @@
|
||||||
<div class="checkForConfiguratorUnstableVersions">
|
<div class="checkForConfiguratorUnstableVersions">
|
||||||
<label><input type="checkbox" /><span i18n="checkForConfiguratorUnstableVersions"></span></label>
|
<label><input type="checkbox" /><span i18n="checkForConfiguratorUnstableVersions"></span></label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="separator"></div>
|
||||||
|
<div class="userLanguage">
|
||||||
|
<label>
|
||||||
|
<span class="dropdown">
|
||||||
|
<select class="dropdown-select" id="userLanguage" i18n_title="userLanguageSelect">
|
||||||
|
<!-- User languages generated here -->
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<span i18n="userLanguageSelect"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue