From a3f1c6f51fab6851b373ebddee90238234d45a8f Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sat, 10 May 2025 12:44:54 -0400 Subject: [PATCH 1/3] [2431] Reimplement Ctypes LongLang Check --- L10n/tr.strings | 3 +-- l10n.py | 43 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/L10n/tr.strings b/L10n/tr.strings index ec416819..68b93b61 100644 --- a/L10n/tr.strings +++ b/L10n/tr.strings @@ -2,8 +2,7 @@ "Error: Frontier CAPI data out of sync" = "Frontier CAPI datası senkronize değil"; /* prefs.py: Appearance option for Windows "Disable Systray"; */ -"Disable Systray" = "Sistem tepsisi ikonunu devre dışı bırak -"; +"Disable Systray" = "Sistem tepsisi ikonunu devre dışı bırak"; /* edsm.py:Settings>EDSM - Label on checkbox for 'send data'; In files: edsm.py:316; */ "Send flight log and CMDR status to EDSM" = "Uçuş günlüğünü ve CMDR durumunu EDSM'e gönder"; diff --git a/l10n.py b/l10n.py index 67b467be..81faed21 100755 --- a/l10n.py +++ b/l10n.py @@ -37,7 +37,17 @@ LANGUAGE_ID = '!Language' LOCALISATION_DIR: pathlib.Path = pathlib.Path('L10n') if sys.platform == 'win32': - import win32api + import ctypes + from ctypes.wintypes import BOOL, DWORD, LPCVOID + + MUI_LANGUAGE_NAME = 0x8 # Use language names like "en-US" + + # Load function from kernel32 + GetUserPreferredUILanguages = ctypes.windll.kernel32.GetUserPreferredUILanguages + GetUserPreferredUILanguages.argtypes = [ + DWORD, ctypes.POINTER(ctypes.c_ulong), LPCVOID, ctypes.POINTER(ctypes.c_ulong) + ] + GetUserPreferredUILanguages.restype = BOOL class Translations: @@ -238,6 +248,17 @@ class Translations: return open(res_path, encoding='utf-8') +def _wszarray_to_list(array): + offset = 0 + while offset < len(array): + sz = ctypes.wstring_at(ctypes.addressof(array) + offset * 2) # type: ignore + if sz: + yield sz + offset += len(sz) + 1 + else: + break + + class _Locale: """Locale holds a few utility methods to convert data to and from localized versions.""" @@ -301,17 +322,29 @@ class _Locale: :return: The preferred language list """ languages: Iterable[str] - if sys.platform != 'win32': # POSIX lang = locale.getlocale()[0] + languages = [lang.replace('_', '-')] if lang else [] else: - current_locale = win32api.GetUserDefaultLangID() - lang = locale.windows_locale[current_locale] + num_langs = ctypes.c_ulong() + buffer_size = ctypes.c_ulong(0) + # First call to get buffer size + if not GetUserPreferredUILanguages( + MUI_LANGUAGE_NAME, ctypes.byref(num_langs), None, ctypes.byref(buffer_size) + ): + raise ctypes.WinError() + # Allocate buffer + buf = ctypes.create_unicode_buffer(buffer_size.value) + # Second call to get languages + if not GetUserPreferredUILanguages( + MUI_LANGUAGE_NAME, ctypes.byref(num_langs), buf, ctypes.byref(buffer_size) + ): + raise ctypes.WinError() + languages = _wszarray_to_list(buf) # HACK: | 2021-12-11: OneSky calls "Chinese Simplified" "zh-Hans" # in the name of the file, but that will be zh-CN in terms of # locale. So map zh-CN -> zh-Hans - languages = [lang.replace('_', '-')] if lang else [] languages = ['zh-Hans' if lang == 'zh-CN' else lang for lang in languages] return languages From 611c5ca13de90e8c8952868dd7d8fde55206cd20 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 11 May 2025 12:57:25 -0400 Subject: [PATCH 2/3] [Minor] Add CobraV and Missing Module --- modules.json | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules.json b/modules.json index 459ee883..f736bcff 100644 --- a/modules.json +++ b/modules.json @@ -104,6 +104,21 @@ "cobramkiv_armour_reactive": { "mass": 27 }, + "cobramkv_armour_grade1": { + "mass": 0 + }, + "cobramkv_armour_grade2": { + "mass": 14 + }, + "cobramkv_armour_grade3": { + "mass": 27 + }, + "cobramkv_armour_mirrored": { + "mass": 27 + }, + "cobramkv_armour_reactive": { + "mass": 27 + }, "cutter_armour_grade1": { "mass": 0 }, @@ -605,6 +620,9 @@ "hpt_heatsinklauncher_turret_tiny": { "mass": 1.3 }, + "hpt_human_extraction_fixed_medium": { + "mass": 4 + }, "hpt_minelauncher_fixed_medium": { "mass": 4 }, @@ -3664,4 +3682,4 @@ "vulture_armour_reactive": { "mass": 35 } -} \ No newline at end of file +} From afa66cd07b7ff528b094f971b8bb83f2b6d73f4f Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 11 May 2025 13:05:17 -0400 Subject: [PATCH 3/3] [Minor] Add Cobra V --- ships.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ships.json b/ships.json index 363cd561..7b2fd62a 100644 --- a/ships.json +++ b/ships.json @@ -39,6 +39,10 @@ "hullMass": 210, "reserveFuelCapacity": 0.51 }, + "Cobra MkV": { + "hullMass": 150, + "reserveFuelCapacity": 0.49 + }, "Diamondback Explorer": { "hullMass": 260, "reserveFuelCapacity": 0.52 @@ -163,4 +167,4 @@ "hullMass": 230, "reserveFuelCapacity": 0.57 } -} \ No newline at end of file +}