prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Localizations revert to defaults on entry of "Locales" menu
  If localizations are changed from the defaults they will revert back to the defaults upon entry of the _Locales_ menu.
  
  </issue>
  <code>
  [start of archinstall/lib/locale/locale_menu.py]
  1 from dataclasses import dataclass
  2 from typing import Dict, Any, TYPE_CHECKING, Optional
  3 
  4 from .locale import set_kb_layout, list_keyboard_languages, list_locales
  5 from ..menu import Selector, AbstractSubMenu, MenuSelectionType, Menu
  6 
  7 if TYPE_CHECKING:
  8 	_: Any
  9 
  10 
  11 @dataclass
  12 class LocaleConfiguration:
  13 	kb_layout: str
  14 	sys_lang: str
  15 	sys_enc: str
  16 
  17 	@staticmethod
  18 	def default() -> 'LocaleConfiguration':
  19 		return LocaleConfiguration('us', 'en_US', 'UTF-8')
  20 
  21 	def json(self) -> Dict[str, str]:
  22 		return {
  23 			'kb_layout': self.kb_layout,
  24 			'sys_lang': self.sys_lang,
  25 			'sys_enc': self.sys_enc
  26 		}
  27 
  28 	@classmethod
  29 	def _load_config(cls, config: 'LocaleConfiguration', args: Dict[str, Any]) -> 'LocaleConfiguration':
  30 		if 'sys_lang' in args:
  31 			config.sys_lang = args['sys_lang']
  32 		if 'sys_enc' in args:
  33 			config.sys_enc = args['sys_enc']
  34 		if 'kb_layout' in args:
  35 			config.kb_layout = args['kb_layout']
  36 
  37 		return config
  38 
  39 	@classmethod
  40 	def parse_arg(cls, args: Dict[str, Any]) -> 'LocaleConfiguration':
  41 		default = cls.default()
  42 
  43 		if 'locale_config' in args:
  44 			default = cls._load_config(default, args['locale_config'])
  45 		else:
  46 			default = cls._load_config(default, args)
  47 
  48 		return default
  49 
  50 
  51 class LocaleMenu(AbstractSubMenu):
  52 	def __init__(
  53 		self,
  54 		data_store: Dict[str, Any],
  55 		locele_conf: LocaleConfiguration
  56 	):
  57 		self._preset = locele_conf
  58 		super().__init__(data_store=data_store)
  59 
  60 	def setup_selection_menu_options(self):
  61 		self._menu_options['keyboard-layout'] = \
  62 			Selector(
  63 				_('Keyboard layout'),
  64 				lambda preset: self._select_kb_layout(preset),
  65 				default='us',
  66 				enabled=True)
  67 		self._menu_options['sys-language'] = \
  68 			Selector(
  69 				_('Locale language'),
  70 				lambda preset: select_locale_lang(preset),
  71 				default='en_US',
  72 				enabled=True)
  73 		self._menu_options['sys-encoding'] = \
  74 			Selector(
  75 				_('Locale encoding'),
  76 				lambda preset: select_locale_enc(preset),
  77 				default='UTF-8',
  78 				enabled=True)
  79 
  80 	def run(self, allow_reset: bool = True) -> LocaleConfiguration:
  81 		super().run(allow_reset=allow_reset)
  82 
  83 		return LocaleConfiguration(
  84 			self._data_store['keyboard-layout'],
  85 			self._data_store['sys-language'],
  86 			self._data_store['sys-encoding']
  87 		)
  88 
  89 	def _select_kb_layout(self, preset: Optional[str]) -> Optional[str]:
  90 		kb_lang = select_kb_layout(preset)
  91 		if kb_lang:
  92 			set_kb_layout(kb_lang)
  93 		return kb_lang
  94 
  95 
  96 def select_locale_lang(preset: Optional[str] = None) -> Optional[str]:
  97 	locales = list_locales()
  98 	locale_lang = set([locale.split()[0] for locale in locales])
  99 
  100 	choice = Menu(
  101 		_('Choose which locale language to use'),
  102 		list(locale_lang),
  103 		sort=True,
  104 		preset_values=preset
  105 	).run()
  106 
  107 	match choice.type_:
  108 		case MenuSelectionType.Selection: return choice.single_value
  109 		case MenuSelectionType.Skip: return preset
  110 
  111 	return None
  112 
  113 
  114 def select_locale_enc(preset: Optional[str] = None) -> Optional[str]:
  115 	locales = list_locales()
  116 	locale_enc = set([locale.split()[1] for locale in locales])
  117 
  118 	choice = Menu(
  119 		_('Choose which locale encoding to use'),
  120 		list(locale_enc),
  121 		sort=True,
  122 		preset_values=preset
  123 	).run()
  124 
  125 	match choice.type_:
  126 		case MenuSelectionType.Selection: return choice.single_value
  127 		case MenuSelectionType.Skip: return preset
  128 
  129 	return None
  130 
  131 
  132 def select_kb_layout(preset: Optional[str] = None) -> Optional[str]:
  133 	"""
  134 	Asks the user to select a language
  135 	Usually this is combined with :ref:`archinstall.list_keyboard_languages`.
  136 
  137 	:return: The language/dictionary key of the selected language
  138 	:rtype: str
  139 	"""
  140 	kb_lang = list_keyboard_languages()
  141 	# sort alphabetically and then by length
  142 	sorted_kb_lang = sorted(sorted(list(kb_lang)), key=len)
  143 
  144 	choice = Menu(
  145 		_('Select keyboard layout'),
  146 		sorted_kb_lang,
  147 		preset_values=preset,
  148 		sort=False
  149 	).run()
  150 
  151 	match choice.type_:
  152 		case MenuSelectionType.Skip: return preset
  153 		case MenuSelectionType.Selection: return choice.single_value
  154 
  155 	return None
  156
  [end of archinstall/lib/locale/locale_menu.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/archinstall/lib/locale/locale_menu.py b/archinstall/lib/locale/locale_menu.py
  --- a/archinstall/lib/locale/locale_menu.py
  +++ b/archinstall/lib/locale/locale_menu.py
  @@ -52,9 +52,9 @@
   	def __init__(
   		self,
   		data_store: Dict[str, Any],
  -		locele_conf: LocaleConfiguration
  +		locale_conf: LocaleConfiguration
   	):
  -		self._preset = locele_conf
  +		self._preset = locale_conf
   		super().__init__(data_store=data_store)
   
   	def setup_selection_menu_options(self):
  @@ -62,19 +62,19 @@
   			Selector(
   				_('Keyboard layout'),
   				lambda preset: self._select_kb_layout(preset),
  -				default='us',
  +				default=self._preset.kb_layout,
   				enabled=True)
   		self._menu_options['sys-language'] = \
   			Selector(
   				_('Locale language'),
   				lambda preset: select_locale_lang(preset),
  -				default='en_US',
  +				default=self._preset.sys_lang,
   				enabled=True)
   		self._menu_options['sys-encoding'] = \
   			Selector(
   				_('Locale encoding'),
   				lambda preset: select_locale_enc(preset),
  -				default='UTF-8',
  +				default=self._preset.sys_enc,
   				enabled=True)
   
   	def run(self, allow_reset: bool = True) -> LocaleConfiguration:
  
verification_info: {"golden_diff": "diff --git a/archinstall/lib/locale/locale_menu.py b/archinstall/lib/locale/locale_menu.py\n--- a/archinstall/lib/locale/locale_menu.py\n+++ b/archinstall/lib/locale/locale_menu.py\n@@ -52,9 +52,9 @@\n \tdef __init__(\n \t\tself,\n \t\tdata_store: Dict[str, Any],\n-\t\tlocele_conf: LocaleConfiguration\n+\t\tlocale_conf: LocaleConfiguration\n \t):\n-\t\tself._preset = locele_conf\n+\t\tself._preset = locale_conf\n \t\tsuper().__init__(data_store=data_store)\n \n \tdef setup_selection_menu_options(self):\n@@ -62,19 +62,19 @@\n \t\t\tSelector(\n \t\t\t\t_('Keyboard layout'),\n \t\t\t\tlambda preset: self._select_kb_layout(preset),\n-\t\t\t\tdefault='us',\n+\t\t\t\tdefault=self._preset.kb_layout,\n \t\t\t\tenabled=True)\n \t\tself._menu_options['sys-language'] = \\\n \t\t\tSelector(\n \t\t\t\t_('Locale language'),\n \t\t\t\tlambda preset: select_locale_lang(preset),\n-\t\t\t\tdefault='en_US',\n+\t\t\t\tdefault=self._preset.sys_lang,\n \t\t\t\tenabled=True)\n \t\tself._menu_options['sys-encoding'] = \\\n \t\t\tSelector(\n \t\t\t\t_('Locale encoding'),\n \t\t\t\tlambda preset: select_locale_enc(preset),\n-\t\t\t\tdefault='UTF-8',\n+\t\t\t\tdefault=self._preset.sys_enc,\n \t\t\t\tenabled=True)\n \n \tdef run(self, allow_reset: bool = True) -> LocaleConfiguration:\n", "issue": "Localizations revert to defaults on entry of \"Locales\" menu\nIf localizations are changed from the defaults they will revert back to the defaults upon entry of the _Locales_ menu.\n", "before_files": [{"content": "from dataclasses import dataclass\nfrom typing import Dict, Any, TYPE_CHECKING, Optional\n\nfrom .locale import set_kb_layout, list_keyboard_languages, list_locales\nfrom ..menu import Selector, AbstractSubMenu, MenuSelectionType, Menu\n\nif TYPE_CHECKING:\n\t_: Any\n\n\n@dataclass\nclass LocaleConfiguration:\n\tkb_layout: str\n\tsys_lang: str\n\tsys_enc: str\n\n\t@staticmethod\n\tdef default() -> 'LocaleConfiguration':\n\t\treturn LocaleConfiguration('us', 'en_US', 'UTF-8')\n\n\tdef json(self) -> Dict[str, str]:\n\t\treturn {\n\t\t\t'kb_layout': self.kb_layout,\n\t\t\t'sys_lang': self.sys_lang,\n\t\t\t'sys_enc': self.sys_enc\n\t\t}\n\n\t@classmethod\n\tdef _load_config(cls, config: 'LocaleConfiguration', args: Dict[str, Any]) -> 'LocaleConfiguration':\n\t\tif 'sys_lang' in args:\n\t\t\tconfig.sys_lang = args['sys_lang']\n\t\tif 'sys_enc' in args:\n\t\t\tconfig.sys_enc = args['sys_enc']\n\t\tif 'kb_layout' in args:\n\t\t\tconfig.kb_layout = args['kb_layout']\n\n\t\treturn config\n\n\t@classmethod\n\tdef parse_arg(cls, args: Dict[str, Any]) -> 'LocaleConfiguration':\n\t\tdefault = cls.default()\n\n\t\tif 'locale_config' in args:\n\t\t\tdefault = cls._load_config(default, args['locale_config'])\n\t\telse:\n\t\t\tdefault = cls._load_config(default, args)\n\n\t\treturn default\n\n\nclass LocaleMenu(AbstractSubMenu):\n\tdef __init__(\n\t\tself,\n\t\tdata_store: Dict[str, Any],\n\t\tlocele_conf: LocaleConfiguration\n\t):\n\t\tself._preset = locele_conf\n\t\tsuper().__init__(data_store=data_store)\n\n\tdef setup_selection_menu_options(self):\n\t\tself._menu_options['keyboard-layout'] = \\\n\t\t\tSelector(\n\t\t\t\t_('Keyboard layout'),\n\t\t\t\tlambda preset: self._select_kb_layout(preset),\n\t\t\t\tdefault='us',\n\t\t\t\tenabled=True)\n\t\tself._menu_options['sys-language'] = \\\n\t\t\tSelector(\n\t\t\t\t_('Locale language'),\n\t\t\t\tlambda preset: select_locale_lang(preset),\n\t\t\t\tdefault='en_US',\n\t\t\t\tenabled=True)\n\t\tself._menu_options['sys-encoding'] = \\\n\t\t\tSelector(\n\t\t\t\t_('Locale encoding'),\n\t\t\t\tlambda preset: select_locale_enc(preset),\n\t\t\t\tdefault='UTF-8',\n\t\t\t\tenabled=True)\n\n\tdef run(self, allow_reset: bool = True) -> LocaleConfiguration:\n\t\tsuper().run(allow_reset=allow_reset)\n\n\t\treturn LocaleConfiguration(\n\t\t\tself._data_store['keyboard-layout'],\n\t\t\tself._data_store['sys-language'],\n\t\t\tself._data_store['sys-encoding']\n\t\t)\n\n\tdef _select_kb_layout(self, preset: Optional[str]) -> Optional[str]:\n\t\tkb_lang = select_kb_layout(preset)\n\t\tif kb_lang:\n\t\t\tset_kb_layout(kb_lang)\n\t\treturn kb_lang\n\n\ndef select_locale_lang(preset: Optional[str] = None) -> Optional[str]:\n\tlocales = list_locales()\n\tlocale_lang = set([locale.split()[0] for locale in locales])\n\n\tchoice = Menu(\n\t\t_('Choose which locale language to use'),\n\t\tlist(locale_lang),\n\t\tsort=True,\n\t\tpreset_values=preset\n\t).run()\n\n\tmatch choice.type_:\n\t\tcase MenuSelectionType.Selection: return choice.single_value\n\t\tcase MenuSelectionType.Skip: return preset\n\n\treturn None\n\n\ndef select_locale_enc(preset: Optional[str] = None) -> Optional[str]:\n\tlocales = list_locales()\n\tlocale_enc = set([locale.split()[1] for locale in locales])\n\n\tchoice = Menu(\n\t\t_('Choose which locale encoding to use'),\n\t\tlist(locale_enc),\n\t\tsort=True,\n\t\tpreset_values=preset\n\t).run()\n\n\tmatch choice.type_:\n\t\tcase MenuSelectionType.Selection: return choice.single_value\n\t\tcase MenuSelectionType.Skip: return preset\n\n\treturn None\n\n\ndef select_kb_layout(preset: Optional[str] = None) -> Optional[str]:\n\t\"\"\"\n\tAsks the user to select a language\n\tUsually this is combined with :ref:`archinstall.list_keyboard_languages`.\n\n\t:return: The language/dictionary key of the selected language\n\t:rtype: str\n\t\"\"\"\n\tkb_lang = list_keyboard_languages()\n\t# sort alphabetically and then by length\n\tsorted_kb_lang = sorted(sorted(list(kb_lang)), key=len)\n\n\tchoice = Menu(\n\t\t_('Select keyboard layout'),\n\t\tsorted_kb_lang,\n\t\tpreset_values=preset,\n\t\tsort=False\n\t).run()\n\n\tmatch choice.type_:\n\t\tcase MenuSelectionType.Skip: return preset\n\t\tcase MenuSelectionType.Selection: return choice.single_value\n\n\treturn None\n", "path": "archinstall/lib/locale/locale_menu.py"}]}