1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-05-21 17:41:20 +03:00

Merge pull request #2434 from HullSeals/fix/2431/localization-breakage

[2431] Reimplement Ctypes LongLang Check
This commit is contained in:
David Sangrey 2025-05-11 13:59:10 -04:00 committed by GitHub
commit 8e725d4e90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 9 deletions

View File

@ -2,8 +2,7 @@
"Error: Frontier CAPI data out of sync" = "Frontier CAPI datası senkronize değil"; "Error: Frontier CAPI data out of sync" = "Frontier CAPI datası senkronize değil";
/* prefs.py: Appearance option for Windows "Disable Systray"; */ /* 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; */ /* 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"; "Send flight log and CMDR status to EDSM" = "Uçuş günlüğünü ve CMDR durumunu EDSM'e gönder";

43
l10n.py
View File

@ -37,7 +37,17 @@ LANGUAGE_ID = '!Language'
LOCALISATION_DIR: pathlib.Path = pathlib.Path('L10n') LOCALISATION_DIR: pathlib.Path = pathlib.Path('L10n')
if sys.platform == 'win32': 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: class Translations:
@ -238,6 +248,17 @@ class Translations:
return open(res_path, encoding='utf-8') 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: class _Locale:
"""Locale holds a few utility methods to convert data to and from localized versions.""" """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 :return: The preferred language list
""" """
languages: Iterable[str] languages: Iterable[str]
if sys.platform != 'win32': if sys.platform != 'win32':
# POSIX # POSIX
lang = locale.getlocale()[0] lang = locale.getlocale()[0]
languages = [lang.replace('_', '-')] if lang else []
else: else:
current_locale = win32api.GetUserDefaultLangID() num_langs = ctypes.c_ulong()
lang = locale.windows_locale[current_locale] 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: <n/a> | 2021-12-11: OneSky calls "Chinese Simplified" "zh-Hans" # HACK: <n/a> | 2021-12-11: OneSky calls "Chinese Simplified" "zh-Hans"
# in the name of the file, but that will be zh-CN in terms of # in the name of the file, but that will be zh-CN in terms of
# locale. So map zh-CN -> zh-Hans # 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] languages = ['zh-Hans' if lang == 'zh-CN' else lang for lang in languages]
return languages return languages

View File

@ -104,6 +104,21 @@
"cobramkiv_armour_reactive": { "cobramkiv_armour_reactive": {
"mass": 27 "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": { "cutter_armour_grade1": {
"mass": 0 "mass": 0
}, },
@ -605,6 +620,9 @@
"hpt_heatsinklauncher_turret_tiny": { "hpt_heatsinklauncher_turret_tiny": {
"mass": 1.3 "mass": 1.3
}, },
"hpt_human_extraction_fixed_medium": {
"mass": 4
},
"hpt_minelauncher_fixed_medium": { "hpt_minelauncher_fixed_medium": {
"mass": 4 "mass": 4
}, },

View File

@ -39,6 +39,10 @@
"hullMass": 210, "hullMass": 210,
"reserveFuelCapacity": 0.51 "reserveFuelCapacity": 0.51
}, },
"Cobra MkV": {
"hullMass": 150,
"reserveFuelCapacity": 0.49
},
"Diamondback Explorer": { "Diamondback Explorer": {
"hullMass": 260, "hullMass": 260,
"reserveFuelCapacity": 0.52 "reserveFuelCapacity": 0.52