Skip to content

Commit 21df662

Browse files
committed
Fixed language selection bug.
1 parent 155d10b commit 21df662

File tree

1 file changed

+46
-58
lines changed

1 file changed

+46
-58
lines changed

omnipkg/i18n.py

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -167,66 +167,48 @@
167167
'zh-Hant': 'Traditional Chinese',
168168
}
169169

170-
# Enhanced language info with native names where available
171-
LANG_INFO = {
172-
'en': {'name': 'English', 'native': 'English'},
173-
'es': {'name': 'Spanish', 'native': 'Español'},
174-
'zh_CN': {'name': 'Chinese (Simplified)', 'native': '中文 (简体)'},
175-
'zh': {'name': 'Chinese', 'native': '中文'},
176-
'hi': {'name': 'Hindi', 'native': 'हिंदी'},
177-
'ar': {'name': 'Arabic', 'native': 'العربية'},
178-
'fr': {'name': 'French', 'native': 'Français'},
179-
'de': {'name': 'German', 'native': 'Deutsch'},
180-
'ja': {'name': 'Japanese', 'native': '日本語'},
181-
'ko': {'name': 'Korean', 'native': '한국어'},
182-
'pt_BR': {'name': 'Portuguese (Brazil)', 'native': 'Português (Brasil)'},
183-
'pt': {'name': 'Portuguese', 'native': 'Português'},
184-
'ru': {'name': 'Russian', 'native': 'Русский'},
185-
'it': {'name': 'Italian', 'native': 'Italiano'},
186-
'nl': {'name': 'Dutch', 'native': 'Nederlands'},
187-
'da': {'name': 'Danish', 'native': 'Dansk'},
188-
'sv': {'name': 'Swedish', 'native': 'Svenska'},
189-
'no': {'name': 'Norwegian', 'native': 'Norsk'},
190-
'fi': {'name': 'Finnish', 'native': 'Suomi'},
191-
'pl': {'name': 'Polish', 'native': 'Polski'},
192-
'cs': {'name': 'Czech', 'native': 'Čeština'},
193-
'hu': {'name': 'Hungarian', 'native': 'Magyar'},
194-
'tr': {'name': 'Turkish', 'native': 'Türkçe'},
195-
'he': {'name': 'Hebrew', 'native': 'עברית'},
196-
'th': {'name': 'Thai', 'native': 'ไทย'},
197-
'vi': {'name': 'Vietnamese', 'native': 'Tiếng Việt'},
198-
'uk': {'name': 'Ukrainian', 'native': 'Українська'},
199-
'bg': {'name': 'Bulgarian', 'native': 'Български'},
200-
'hr': {'name': 'Croatian', 'native': 'Hrvatski'},
201-
'sr': {'name': 'Serbian', 'native': 'Српски'},
202-
'sl': {'name': 'Slovenian', 'native': 'Slovenščina'},
203-
'sk': {'name': 'Slovak', 'native': 'Slovenčina'},
204-
'ro': {'name': 'Romanian', 'native': 'Română'},
205-
'el': {'name': 'Greek', 'native': 'Ελληνικά'},
206-
'bn': {'name': 'Bengali', 'native': 'বাংলা'},
207-
'ur': {'name': 'Urdu', 'native': 'اردو'},
208-
'fa': {'name': 'Persian', 'native': 'فارسی'},
209-
'ta': {'name': 'Tamil', 'native': 'தமிழ்'},
210-
'te': {'name': 'Telugu', 'native': 'తెలుగు'},
211-
'mr': {'name': 'Marathi', 'native': 'मराठी'},
212-
'gu': {'name': 'Gujarati', 'native': 'ગુજરાતી'},
213-
'kn': {'name': 'Kannada', 'native': 'ಕನ್ನಡ'},
214-
'ml': {'name': 'Malayalam', 'native': 'മലയാളം'},
215-
'pa': {'name': 'Punjabi', 'native': 'ਪੰਜਾਬੀ'},
216-
'id': {'name': 'Indonesian', 'native': 'Bahasa Indonesia'},
217-
'ms': {'name': 'Malay', 'native': 'Bahasa Melayu'},
218-
'tl': {'name': 'Tagalog', 'native': 'Tagalog'},
219-
'sw': {'name': 'Swahili', 'native': 'Kiswahili'},
220-
'am': {'name': 'Amharic', 'native': 'አማርኛ'},
221-
'yo': {'name': 'Yoruba', 'native': 'Yorùbá'},
222-
'ig': {'name': 'Igbo', 'native': 'Igbo'},
223-
'ha': {'name': 'Hausa', 'native': 'Hausa'},
170+
# Separate available languages from coming soon ones
171+
AVAILABLE_LANGUAGES = {
172+
'en': {'name': 'English', 'native': 'English', 'hello': 'Hello'},
173+
'am': {'name': 'Amharic', 'native': 'አማርኛ', 'hello': 'ሰላም'},
174+
'ar': {'name': 'Arabic', 'native': 'العربية', 'hello': 'مرحبا'},
175+
'ar_eg': {'name': 'Arabic (Egypt)', 'native': 'العربية (مصر)', 'hello': 'مرحبا'},
176+
'bn': {'name': 'Bengali', 'native': 'বাংলা', 'hello': 'হ্যালো'},
177+
'da': {'name': 'Danish', 'native': 'Dansk', 'hello': 'Hej'},
178+
'de': {'name': 'German', 'native': 'Deutsch', 'hello': 'Hallo'},
179+
'es': {'name': 'Spanish', 'native': 'Español', 'hello': 'Hola'},
180+
'fr': {'name': 'French', 'native': 'Français', 'hello': 'Bonjour'},
181+
'hi': {'name': 'Hindi', 'native': 'हिंदी', 'hello': 'नमस्ते'},
182+
'hr': {'name': 'Croatian', 'native': 'Hrvatski', 'hello': 'Bok'},
183+
'id': {'name': 'Indonesian', 'native': 'Bahasa Indonesia', 'hello': 'Halo'},
184+
'it': {'name': 'Italian', 'native': 'Italiano', 'hello': 'Ciao'},
185+
'ja': {'name': 'Japanese', 'native': '日本語', 'hello': 'こんにちは'},
186+
'ko': {'name': 'Korean', 'native': '한국어', 'hello': '안녕하세요'},
187+
'nl': {'name': 'Dutch', 'native': 'Nederlands', 'hello': 'Hallo'},
188+
'no': {'name': 'Norwegian', 'native': 'Norsk', 'hello': 'Hei'},
189+
'pl': {'name': 'Polish', 'native': 'Polski', 'hello': 'Cześć'},
190+
'pt_BR': {'name': 'Portuguese (Brazil)', 'native': 'Português (Brasil)', 'hello': 'Olá'},
191+
'ru': {'name': 'Russian', 'native': 'Русский', 'hello': 'Привет'},
192+
'sv': {'name': 'Swedish', 'native': 'Svenska', 'hello': 'Hej'},
193+
'sw': {'name': 'Swahili', 'native': 'Kiswahili', 'hello': 'Hujambo'},
194+
'tr': {'name': 'Turkish', 'native': 'Türkçe', 'hello': 'Merhaba'},
195+
'vi': {'name': 'Vietnamese', 'native': 'Tiếng Việt', 'hello': 'Xin chào'},
196+
'zh_CN': {'name': 'Chinese (Simplified)', 'native': '中文 (简体)', 'hello': '你好'},
224197
}
225198

226-
# Merge any additional languages from LANGUAGE_CODE_MAP that aren't in LANG_INFO
199+
# Coming soon languages - just show names, no selection
200+
COMING_SOON_LANGUAGES = []
227201
for code, name in LANGUAGE_CODE_MAP.items():
228-
if code not in LANG_INFO:
229-
LANG_INFO[code] = {'name': name, 'native': name}
202+
if code not in AVAILABLE_LANGUAGES:
203+
COMING_SOON_LANGUAGES.append(name)
204+
205+
# Sort coming soon alphabetically
206+
COMING_SOON_LANGUAGES.sort()
207+
208+
# Use AVAILABLE_LANGUAGES as LANG_INFO for backward compatibility
209+
LANG_INFO = AVAILABLE_LANGUAGES
210+
211+
# Don't add other languages - only show what's actually available
230212

231213
# This is the variable that your cli.py is trying to import
232214
SUPPORTED_LANGUAGES = {code: data['native'] for code, data in LANG_INFO.items()}
@@ -299,6 +281,12 @@ def get_native_name(self, code=None):
299281
code = self.current_lang
300282
return LANG_INFO.get(code, {}).get('native', LANGUAGE_CODE_MAP.get(code, code))
301283

284+
def get_hello(self, code=None):
285+
"""Get the hello greeting for a language."""
286+
if code is None:
287+
code = self.current_lang
288+
return LANG_INFO.get(code, {}).get('hello', 'Hello')
289+
302290
def is_supported(self, code):
303291
"""Check if a language code is supported."""
304292
return code in LANGUAGE_CODE_MAP or code in LANG_INFO
@@ -317,5 +305,5 @@ def get_language_info(code):
317305
if code in LANG_INFO:
318306
return LANG_INFO[code]
319307
elif code in LANGUAGE_CODE_MAP:
320-
return {'name': LANGUAGE_CODE_MAP[code], 'native': LANGUAGE_CODE_MAP[code]}
308+
return {'name': LANGUAGE_CODE_MAP[code], 'native': LANGUAGE_CODE_MAP[code], 'hello': 'Hello'}
321309
return None

0 commit comments

Comments
 (0)