300250
// This StringList (LogoLanguageList) is a list of all possible language codes all possible [en_US, fr, nl, etc.]. It is used to (1) find the LogoLanguage variable (that is defined later on), and (2) in the Settings dialog to fill the language ComboBox. Better not to dupe this code. The LogoLanguageList is made pretty in the slotSettings class of kturtle.cpp.
// We assume keyword and highlight files come in pairs (if not there will be no highlight style)
TQStringList xmlFiles = KGlobal::dirs()->findAllResources("data", "kturtle/data/*.xml");
TQStringList LogoLanguageList;
TQString xmlTranslationFiles; // for debug purposes
for ( TQStringList::Iterator it = xmlFiles.begin(); it != xmlFiles.end(); ++it ) {
TQString xmlFile(*it);
xmlTranslationFiles += xmlFile.section('.', -2, -2).append(", "); // for debug purposes
// build list of language codes (en_US, nl, etc.)
LogoLanguageList += xmlFile.section('.', -2, -2);
}
kdDebug(0) << "Available translations of Logo: "<< xmlTranslationFiles <<endl;
LogoLanguageList.sort();
LogoLanguageList
// This is the String (LogoLanguage) that actually gets picked up by the app to know what XML files (for HLstyle and Logo language) to use. It is not directly changeable by the ComboBox but is translated from the Ints that ComboBox LogoLanguageList emits. It is better to have the logic that changes the Ints to Strings at the settings dept.
// The KconfigXT framework makes shure the value that is saved in the kturtlerc file will be used in stead of the defaultLanguage that we find here.
// Get the desktops language
KConfigBase *globalConf = KGlobal::config();
globalConf->setGroup("Locale");
TQString desktopLanguage = globalConf->readEntry("Language");
kdDebug(0) << "desktopLanguage: "<< desktopLanguage <<endl;
TQString defaultLanguage = "en_US"; // init to the fall back value
int itemCount = 0; // for the LanguageComboBox
for (TQStringList::Iterator it = LogoLanguageList.begin(); it != LogoLanguageList.end(); ++it ) {
TQString testLanguage(*it);
if (testLanguage == desktopLanguage) { // exact match
defaultLanguage = testLanguage;
break;
} else if ( testLanguage.left(2) == desktopLanguage.left(2) ) { // close match (different dialect)
// The default language must still be one of the kturtle languages.
// defaultLanguage = testLanguage.left(2);
defaultLanguage = testLanguage;
break;
}
itemCount++;
}
kdDebug(0) << "Logo command language: "<< defaultLanguage <<endl;
defaultLanguage
// This is the parameter that actually gets changed (and emits the signal to the dialog to enable the Apply and Defaults buttons). This value is saved in the kturtlerc file but is never used.
itemCount