Commit 84158f09 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

core, in activity language setting, replace 'your system default' with 'GCompris' language'

parent d1458380
......@@ -87,6 +87,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -117,13 +119,23 @@ ActivityBase {
}
onClose: home()
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
background.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(dataToSave && dataToSave["locale"]) {
background.locale = dataToSave["locale"];
setLocale(dataToSave["locale"]);
}
else {
setLocale(background.locale)
}
}
onSaveData: {
var oldLocale = background.locale;
var oldLocale = configurationLocale;
var newLocale =
dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
......@@ -132,7 +144,7 @@ ActivityBase {
}
dataToSave = {"locale": newLocale }
background.locale = newLocale;
setLocale(newLocale)
// Restart the activity with new information
if(oldLocale !== newLocale) {
......@@ -142,8 +154,8 @@ ActivityBase {
}
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -22,6 +22,7 @@ import QtQuick 2.6
import GCompris 1.0
import "../../core"
import "qrc:/gcompris/src/core/core.js" as Core
Item {
id: activityConfiguration
......@@ -32,6 +33,7 @@ Item {
property int speedSetting: 10
property bool uppercaseOnly: false
property string locale: "system"
property string configurationLocale: "system"
width: if(background) background.width
property alias availableLangs: langs.languages
LanguageList {
......@@ -76,6 +78,12 @@ Item {
}
}
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
activityConfiguration.locale = Core.resolveLocale(localeToSet)
}
property var dataToSave
function setDefaultValues() {
// Recreate the binding
......@@ -87,19 +95,14 @@ Item {
localeUtf8 += ".UTF-8";
}
for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) {
if(activityConfiguration.availableLangs[i].locale === localeUtf8) {
activityConfiguration.localeBox.currentIndex = i;
break;
}
}
if(dataToSave.locale) {
activityConfiguration.locale = localeUtf8
activityConfiguration.locale = activityConfiguration.availableLangs[0].locale
setLocale(localeUtf8)
}
else {
localeBox.currentIndex = 0
activityConfiguration.localeBox.currentIndex = 0
setLocale(activityConfiguration.availableLangs[0].locale)
}
activityConfiguration.uppercaseOnly = (dataToSave.uppercaseMode === "true")
if(dataToSave.speedSetting) {
activityConfiguration.speedSetting = dataToSave.speedSetting
......@@ -107,6 +110,13 @@ Item {
else {
activityConfiguration.speedSetting = 10
}
for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) {
if(activityConfiguration.availableLangs[i].locale === localeUtf8) {
activityConfiguration.localeBox.currentIndex = i;
break;
}
}
}
function saveValues() {
......@@ -120,7 +130,7 @@ Item {
speedSetting = speedSlider.value
dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting}
activityConfiguration.locale = newLocale;
setLocale(newLocale);
dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting, "activityLocale": activityConfiguration.locale}
}
}
......@@ -24,6 +24,7 @@ import QtQuick 2.6
import GCompris 1.0
import "../../core"
import "qrc:/gcompris/src/core/core.js" as Core
import "gletters.js" as Activity
ActivityBase {
......@@ -193,10 +194,13 @@ ActivityBase {
}
onLoadData: {
if (activity.activityName === "gletters") {
if(activityData && activityData["locale"]) {
background.locale = activityData["locale"];
if(activityData && activityData["activityLocale"]) {
background.locale = activityData["activityLocale"];
activity.uppercaseOnly = activityData["uppercaseMode"] === "true" ? true : false;
}
else {
background.locale = Core.resolveLocale(background.locale)
}
} else if (activity.activityName === "smallnumbers2") {
if(activityData && activityData["mode"]) {
activity.dominoMode = activityData["mode"];
......@@ -270,7 +274,5 @@ ActivityBase {
repeat: false
onTriggered: Activity.dropWord();
}
}
}
......@@ -245,6 +245,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -285,16 +287,26 @@ ActivityBase {
}
onClose: home()
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
background.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(dataToSave && dataToSave["locale"]) {
background.locale = dataToSave["locale"];
setLocale(dataToSave["locale"]);
}
else {
setLocale(background.locale)
}
if(dataToSave && dataToSave["easyMode"]) {
items.easyMode = (dataToSave["easyMode"] === "true");
}
}
onSaveData: {
var oldLocale = background.locale;
var oldLocale = configurationLocale;
var newLocale =
dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
......@@ -304,7 +316,7 @@ ActivityBase {
dataToSave = {"locale": newLocale,
"easyMode": "" + items.easyMode }
background.locale = newLocale;
setLocale(newLocale);
// Restart the activity with new information
if(oldLocale !== newLocale) {
......@@ -314,8 +326,8 @@ ActivityBase {
}
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -155,6 +155,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -185,18 +187,27 @@ ActivityBase {
}
}
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
items.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(!dataToSave)
return
if(dataToSave['locale']) {
items.locale = dataToSave["locale"];
setLocale(dataToSave["locale"]);
}
else {
setLocale(items.locale);
}
}
onSaveData: {
// Save the lessons status on the current locale
var oldLocale = items.locale
dataToSave[ApplicationInfo.getVoicesLocale(items.locale)] =
var oldLocale = configurationLocale
dataToSave[ApplicationInfo.getVoicesLocale(oldLocale)] =
Activity.lessonsToSavedProperties(dataToSave)
if(!dialogActivityConfig.loader.item)
......@@ -210,7 +221,7 @@ ActivityBase {
newLocale = newLocale.substring(0, newLocale.indexOf('.'))
}
dataToSave['locale'] = newLocale
items.locale = newLocale;
setLocale(newLocale)
// Restart the activity with new information
if(oldLocale !== newLocale) {
......@@ -221,8 +232,8 @@ ActivityBase {
function setDefaultValues() {
var localeUtf8 = items.locale;
if(items.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -120,7 +120,6 @@ Image {
keyNavigationWraps: true
property int spacing: 10
delegate: Item {
id: delegateItem
width: levelCellWidth - menuGrid.spacing
......
......@@ -104,6 +104,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -172,6 +174,13 @@ ActivityBase {
}
onClose: home()
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
background.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(dataToSave && dataToSave["savedMode"]) {
items.currentMode = dataToSave["savedMode"] === "5" ? items.easyModeWordCount : items.normalModeWordCount
......@@ -182,11 +191,14 @@ ActivityBase {
}
if(dataToSave && dataToSave["locale"]) {
background.locale = dataToSave["locale"];
setLocale(dataToSave["locale"])
}
else {
setLocale(background.locale)
}
}
onSaveData: {
var oldLocale = background.locale;
var oldLocale = configurationLocale;
var newLocale =
dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
......@@ -202,7 +214,7 @@ ActivityBase {
dataToSave = {"locale": newLocale, "savedMode": items.currentMode, "savedLetterCase": items.currentLetterCase}
background.locale = newLocale;
setLocale(newLocale)
// Restart the activity with new information
if(oldLocale !== newLocale || oldMode !== items.currentMode || oldLetterCase !== items.currentLetterCase) {
......@@ -212,8 +224,8 @@ ActivityBase {
}
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -36,6 +36,7 @@ Item {
LanguageList {
id: allLangs
inMenu: true
}
Column {
......
......@@ -23,6 +23,7 @@ import QtQuick 2.6
import GCompris 1.0
import "../../core"
import "qrc:/gcompris/src/core/core.js" as Core
import "missing-letter.js" as Activity
ActivityBase {
......@@ -253,6 +254,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -283,13 +286,23 @@ ActivityBase {
}
onClose: home()
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
background.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(dataToSave && dataToSave["locale"]) {
background.locale = dataToSave["locale"];
setLocale(dataToSave["locale"])
}
else {
setLocale(background.locale)
}
}
onSaveData: {
var oldLocale = background.locale;
var oldLocale = configurationLocale;
var newLocale =
dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
......@@ -298,8 +311,7 @@ ActivityBase {
}
dataToSave = {"locale": newLocale }
background.locale = newLocale;
setLocale(newLocale)
// Restart the activity with new information
if(oldLocale !== newLocale) {
background.stop();
......@@ -309,8 +321,8 @@ ActivityBase {
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -80,6 +80,8 @@ ActivityBase {
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
property string configurationLocale: "system"
content: Component {
Item {
property alias localeBox: localeBox
......@@ -130,20 +132,28 @@ ActivityBase {
}
onClose: home()
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
background.locale = Core.resolveLocale(localeToSet)
}
onLoadData: {
if(dataToSave) {
if(dataToSave["locale"]) {
background.locale = dataToSave["locale"];
setLocale(dataToSave["locale"]);
}
if(dataToSave["speedSetting"]) {
activity.speedSetting = dataToSave["speedSetting"];
}
}
if(dataToSave) {
if(dataToSave["speedSetting"]) {
activity.speedSetting = dataToSave["speedSetting"];
}
else {
setLocale(background.locale)
}
}
onSaveData: {
var oldLocale = background.locale;
var oldLocale = configurationLocale;
var newLocale = dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
if(newLocale.indexOf('.') !== -1) {
......@@ -153,11 +163,11 @@ ActivityBase {
"locale": newLocale,
}
background.locale = newLocale;
setLocale(newLocale);
// Restart the activity with new information
if(oldLocale !== newLocale) {
background.stop();
wordDisplayList.layoutDirection = Core.isLeftToRightLocale(background.locale) ? Qt.LeftToRight : Qt.RightToLeft;
wordDisplayList.layoutDirection = Core.isLeftToRightLocale(configurationLocale) ? Qt.LeftToRight : Qt.RightToLeft;
background.start();
}
var oldSpeed = activity.speedSetting
......@@ -170,8 +180,8 @@ ActivityBase {
}
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
var localeUtf8 = configurationLocale;
if(configurationLocale != "system") {
localeUtf8 += ".UTF-8";
}
......
......@@ -22,6 +22,7 @@ import QtQuick 2.6
import GCompris 1.0
import "../../core"
import "qrc:/gcompris/src/core/core.js" as Core
Item {
id: activityConfiguration
......@@ -32,6 +33,7 @@ Item {
property alias speedSlider: speedSlider
property int speedSetting: 10
property string locale: "system"
property string configurationLocale: "system"
width: if(background) background.width
property alias availableLangs: langs.languages
LanguageList {
......@@ -76,6 +78,12 @@ Item {
}
}
function setLocale(localeToSet) {
// Store the locale as-is to be displayed in menu
configurationLocale = localeToSet
activityConfiguration.locale = Core.resolveLocale(localeToSet)
}
property var dataToSave
function setDefaultValues() {
// Recreate the binding
......@@ -87,19 +95,21 @@ Item {
localeUtf8 += ".UTF-8";
}
if(dataToSave.locale) {
setLocale(localeUtf8)
}
else {
activityConfiguration.localeBox.currentIndex = 0
setLocale(activityConfiguration.availableLangs[0].locale)
}
for(var i = 0 ; i < activityConfiguration.availableLangs.length ; i ++) {
if(activityConfiguration.availableLangs[i].locale === localeUtf8) {
activityConfiguration.localeBox.currentIndex = i;
break;
}
}
if(dataToSave.locale) {
activityConfiguration.locale = localeUtf8
}
else {
localeBox.currentIndex = 0
activityConfiguration.locale = activityConfiguration.availableLangs[0].locale
}
activityConfiguration.uppercaseOnly = (dataToSave.uppercaseMode === "true")
if(dataToSave.speedSetting) {
activityConfiguration.speedSetting = dataToSave.speedSetting
......@@ -120,7 +130,7 @@ Item {
speedSetting = speedSlider.value
dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting}
activityConfiguration.locale = newLocale;
setLocale(newLocale);
dataToSave = {"locale": newLocale, "uppercaseMode": "" + activityConfiguration.uppercaseOnly, "speedSetting": speedSetting, "activityLocale": activityConfiguration.locale}
}
}
......@@ -28,6 +28,8 @@ import QtQuick 2.6
* Put here the locales for which we have a good enough translation.
*/
QtObject {
property bool inMenu: false
/**
* type:list
* List of language objects.
......@@ -40,7 +42,7 @@ QtObject {
* standard locale.
*/
property var languages: [
{ "text": qsTr("Your system default"), "locale": "system" },
{ "text": inMenu ? qsTr("Your system default") : qsTr("GCompris' language"), "locale": "system" },
{ "text": "UK English", "locale": "en_GB.UTF-8" },
{ "text": "American English", "locale": "en_US.UTF-8" },
//{ "text": "български", "locale": "bg_BG.UTF-8" },
......
......@@ -244,3 +244,21 @@ function isLeftToRightLocale(locale) {
var localeShort = GCompris.ApplicationInfo.getVoicesLocale(locale)
return (localeShort != "ar" && localeShort != "he");
}
function resolveLocale(localeToSet) {
// Resolve the locale used to a real one
// if Gcompris' locale selected, we want the real locale
// and if GCompris' locale is system, then resolve again
var newLocale = localeToSet
if(newLocale === "system") {
newLocale = GCompris.ApplicationSettings.locale
// Remove .UTF-8
if(newLocale.indexOf('.') != -1) {
newLocale = newLocale.substring(0, newLocale.indexOf('.'))
}
return newLocale
}
else {
return localeToSet
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment