|
10 | 10 | #include "gucc/file_utils.hpp"
|
11 | 11 | #include "gucc/initcpio.hpp"
|
12 | 12 | #include "gucc/io_utils.hpp"
|
| 13 | +#include "gucc/locale.hpp" |
13 | 14 | #include "gucc/luks.hpp"
|
14 | 15 | #include "gucc/pacmanconf_repo.hpp"
|
15 | 16 | #include "gucc/string_utils.hpp"
|
@@ -388,31 +389,13 @@ void set_hostname(const std::string_view& hostname) noexcept {
|
388 | 389 | void set_locale(const std::string_view& locale) noexcept {
|
389 | 390 | spdlog::info("Selected locale: {}", locale);
|
390 | 391 | #ifdef NDEVENV
|
391 |
| - auto* config_instance = Config::instance(); |
392 |
| - auto& config_data = config_instance->data(); |
393 |
| - const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]); |
394 |
| - const auto& locale_config_path = fmt::format(FMT_COMPILE("{}/etc/locale.conf"), mountpoint); |
395 |
| - const auto& locale_gen_path = fmt::format(FMT_COMPILE("{}/etc/locale.gen"), mountpoint); |
396 |
| - |
397 |
| - static constexpr auto locale_config_part = R"(LANG="{0}" |
398 |
| -LC_NUMERIC="{0}" |
399 |
| -LC_TIME="{0}" |
400 |
| -LC_MONETARY="{0}" |
401 |
| -LC_PAPER="{0}" |
402 |
| -LC_NAME="{0}" |
403 |
| -LC_ADDRESS="{0}" |
404 |
| -LC_TELEPHONE="{0}" |
405 |
| -LC_MEASUREMENT="{0}" |
406 |
| -LC_IDENTIFICATION="{0}" |
407 |
| -LC_MESSAGES="{0}")"; |
408 |
| - |
409 |
| - std::ofstream locale_config_file{locale_config_path}; |
410 |
| - locale_config_file << fmt::format(locale_config_part, locale); |
411 |
| - |
412 |
| - gucc::utils::exec(fmt::format(FMT_COMPILE("sed -i \"s/#{0}/{0}/\" {1}"), locale, locale_gen_path)); |
413 |
| - |
414 |
| - // Generate locales |
415 |
| - utils::arch_chroot("locale-gen", false); |
| 392 | + auto* config_instance = Config::instance(); |
| 393 | + auto& config_data = config_instance->data(); |
| 394 | + const auto& mountpoint = std::get<std::string>(config_data["MOUNTPOINT"]); |
| 395 | + |
| 396 | + if (!gucc::locale::set_locale(locale, mountpoint)) { |
| 397 | + spdlog::error("Failed to set locale"); |
| 398 | + } |
416 | 399 | #endif
|
417 | 400 | }
|
418 | 401 |
|
|
0 commit comments