-rw-r--r-- | noncore/settings/language/language.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp index 397d372..5c4284b 100644 --- a/noncore/settings/language/language.cpp +++ b/noncore/settings/language/language.cpp | |||
@@ -61,12 +61,13 @@ | |||
61 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) | 61 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) |
62 | : LanguageSettingsBase( parent, name, TRUE, fl ) | 62 | : LanguageSettingsBase( parent, name, TRUE, fl ) |
63 | { | 63 | { |
64 | if ( FontManager::hasUnicodeFont() ) | 64 | if ( FontManager::hasUnicodeFont() ) |
65 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); | 65 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); |
66 | 66 | ||
67 | |||
67 | QString tfn = QPEApplication::qpeDir()+"/i18n/"; | 68 | QString tfn = QPEApplication::qpeDir()+"/i18n/"; |
68 | QDir langDir = tfn; | 69 | QDir langDir = tfn; |
69 | QStringList list = langDir.entryList("*", QDir::Dirs ); | 70 | QStringList list = langDir.entryList("*", QDir::Dirs ); |
70 | 71 | ||
71 | QStringList::Iterator it; | 72 | QStringList::Iterator it; |
72 | 73 | ||
@@ -83,46 +84,50 @@ LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags f | |||
83 | if ( !ownName.isEmpty() && ownName != langName ) | 84 | if ( !ownName.isEmpty() && ownName != langName ) |
84 | langName = langName + " [" + ownName + "]"; | 85 | langName = langName + " [" + ownName + "]"; |
85 | languages->insertItem( langName ); | 86 | languages->insertItem( langName ); |
86 | 87 | ||
87 | } | 88 | } |
88 | } | 89 | } |
90 | if ( langAvail. find ( "en" ) == -1 ) { | ||
91 | langAvail. prepend ( "" ); // no tr | ||
92 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); | ||
93 | } | ||
89 | 94 | ||
90 | dl = new QPEDialogListener(this); | 95 | dl = new QPEDialogListener(this); |
91 | reset(); | 96 | reset(); |
92 | } | 97 | } |
93 | 98 | ||
94 | LanguageSettings::~LanguageSettings() | 99 | LanguageSettings::~LanguageSettings() |
95 | { | 100 | {} |
96 | } | ||
97 | 101 | ||
98 | void LanguageSettings::accept() | 102 | void LanguageSettings::accept() |
99 | { | 103 | { |
100 | applyLanguage(); | 104 | applyLanguage(); |
101 | QDialog::accept(); | 105 | QDialog::accept(); |
102 | } | 106 | } |
103 | 107 | ||
104 | void LanguageSettings::applyLanguage() | 108 | void LanguageSettings::applyLanguage() |
105 | { | 109 | { |
106 | QString lang = langAvail.at( languages->currentItem() ); | 110 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); |
107 | setLanguage( lang ); | ||
108 | } | 111 | } |
109 | 112 | ||
110 | 113 | ||
111 | void LanguageSettings::reject() | 114 | void LanguageSettings::reject() |
112 | { | 115 | { |
113 | reset(); | 116 | reset(); |
114 | QDialog::reject(); | 117 | QDialog::reject(); |
115 | } | 118 | } |
116 | 119 | ||
117 | void LanguageSettings::reset() | 120 | void LanguageSettings::reset() |
118 | { | 121 | { |
119 | QString l = getenv("LANG"); | 122 | QString l = getenv("LANG"); |
120 | Config config("language"); | 123 | Config config("locale"); |
124 | config.setGroup("Language"); | ||
121 | l = config.readEntry( "Language", l ); | 125 | l = config.readEntry( "Language", l ); |
122 | if(l.isEmpty()) l = "en"; | 126 | if (l.isEmpty()) |
127 | l = "en"; | ||
123 | actualLanguage = l; | 128 | actualLanguage = l; |
124 | 129 | ||
125 | int n = langAvail.find( l ); | 130 | int n = langAvail.find( l ); |
126 | languages->setCurrentItem( n ); | 131 | languages->setCurrentItem( n ); |
127 | } | 132 | } |
128 | 133 | ||
@@ -130,19 +135,24 @@ QString LanguageSettings::actualLanguage; | |||
130 | 135 | ||
131 | void LanguageSettings::setLanguage(const QString& lang) | 136 | void LanguageSettings::setLanguage(const QString& lang) |
132 | { | 137 | { |
133 | if( lang != actualLanguage ) { | 138 | if( lang != actualLanguage ) { |
134 | Config config("locale"); | 139 | Config config("locale"); |
135 | config.setGroup( "Language" ); | 140 | config.setGroup( "Language" ); |
141 | if ( lang. isEmpty ( )) | ||
142 | config. removeEntry ( "Language" ); | ||
143 | else | ||
136 | config.writeEntry( "Language", lang ); | 144 | config.writeEntry( "Language", lang ); |
137 | config.write(); | 145 | config.write(); |
138 | 146 | ||
139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 147 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
148 | |||
140 | QCopEnvelope e("QPE/System","language(QString)"); | 149 | QCopEnvelope e("QPE/System","language(QString)"); |
141 | e << lang; | 150 | e << lang; |
142 | #endif | 151 | #endif |
152 | |||
143 | } | 153 | } |
144 | } | 154 | } |
145 | 155 | ||
146 | void LanguageSettings::done(int r) | 156 | void LanguageSettings::done(int r) |
147 | { | 157 | { |
148 | QDialog::done(r); | 158 | QDialog::done(r); |