diff --git a/archinstall/lib/locale_helpers.py b/archinstall/lib/locale_helpers.py index 83df7f14bf..53912025d4 100644 --- a/archinstall/lib/locale_helpers.py +++ b/archinstall/lib/locale_helpers.py @@ -186,6 +186,7 @@ def uncomment(self) -> bool: return False index = 0 + locales = self.locales.copy() # Comment all uncommented entries. for index, entry in enumerate(contents): @@ -204,8 +205,13 @@ def uncomment(self) -> bool: if locale == Locale(*uncommented_entry.strip().split()): contents[index] = uncommented_entry + locales.remove(locale) break + # Append locales that are supported but did not match entries. + for locale in locales: + contents.append(f'{locale.name} {locale.encoding}\n') + # Open the file again in write mode, to replace the contents. try: with open(self.locale_gen, 'w') as fh: @@ -391,25 +397,16 @@ def run(self) -> bool: def list_locales(target: str = '') -> List[str]: supported = f'{target}/usr/share/i18n/SUPPORTED' - locales = [] try: with open(supported, 'r') as fh: - entries = fh.readlines() + locales = fh.readlines() except FileNotFoundError: log(f"Supported locale file not found: '{supported}'", fg="red", level=logging.ERROR) - else: - # Remove lines that do not contain locales. - for index, line in enumerate(entries): - if line == 'SUPPORTED-LOCALES=\\\n': - entries = entries[index + 1:] - break - - # Remove C.UTF-8 since it is provided by the glibc package. - entries.remove('C.UTF-8/UTF-8 \\\n') + return None - for entry in entries: - locales.append(entry[:-3].replace('/', ' ')) + # Remove C.UTF-8 since it is provided by the glibc package. + locales.remove('C.UTF-8 UTF-8\n') return locales