mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-02-02 22:07:13 +08:00
🧹 move locale get into gucc
This commit is contained in:
parent
4b35d00724
commit
2a88ecd313
@ -1,7 +1,9 @@
|
|||||||
#ifndef LOCALE_HPP
|
#ifndef LOCALE_HPP
|
||||||
#define LOCALE_HPP
|
#define LOCALE_HPP
|
||||||
|
|
||||||
|
#include <string> // for string
|
||||||
#include <string_view> // for string_view
|
#include <string_view> // for string_view
|
||||||
|
#include <vector> // for vector
|
||||||
|
|
||||||
namespace gucc::locale {
|
namespace gucc::locale {
|
||||||
|
|
||||||
@ -12,6 +14,9 @@ auto set_locale(std::string_view locale, std::string_view mountpoint) noexcept -
|
|||||||
// Sets without updating system locale
|
// Sets without updating system locale
|
||||||
auto prepare_locale_set(std::string_view locale, std::string_view mountpoint) noexcept -> bool;
|
auto prepare_locale_set(std::string_view locale, std::string_view mountpoint) noexcept -> bool;
|
||||||
|
|
||||||
|
// List possible locales
|
||||||
|
auto get_possible_locales() noexcept -> std::vector<std::string>;
|
||||||
|
|
||||||
} // namespace gucc::locale
|
} // namespace gucc::locale
|
||||||
|
|
||||||
#endif // LOCALE_HPP
|
#endif // LOCALE_HPP
|
||||||
|
@ -60,4 +60,9 @@ auto set_locale(std::string_view locale, std::string_view mountpoint) noexcept -
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto get_possible_locales() noexcept -> std::vector<std::string> {
|
||||||
|
const auto& locales = utils::exec("cat /etc/locale.gen | grep -v '# ' | sed 's/#//g' | awk '/UTF-8/ {print $1}'");
|
||||||
|
return utils::make_multiline(locales);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gucc::locale
|
} // namespace gucc::locale
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "definitions.hpp"
|
#include "definitions.hpp"
|
||||||
#include "disk.hpp"
|
#include "disk.hpp"
|
||||||
#include "drivers.hpp"
|
#include "drivers.hpp"
|
||||||
|
#include "gucc/locale.hpp"
|
||||||
#include "misc.hpp"
|
#include "misc.hpp"
|
||||||
#include "simple_tui.hpp"
|
#include "simple_tui.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
@ -12,6 +13,7 @@
|
|||||||
// import gucc
|
// import gucc
|
||||||
#include "gucc/fs_utils.hpp"
|
#include "gucc/fs_utils.hpp"
|
||||||
#include "gucc/io_utils.hpp"
|
#include "gucc/io_utils.hpp"
|
||||||
|
#include "gucc/locale.hpp"
|
||||||
#include "gucc/string_utils.hpp"
|
#include "gucc/string_utils.hpp"
|
||||||
#include "gucc/zfs.hpp"
|
#include "gucc/zfs.hpp"
|
||||||
|
|
||||||
@ -178,7 +180,7 @@ void set_hostname() noexcept {
|
|||||||
|
|
||||||
// Set system language
|
// Set system language
|
||||||
void set_locale() noexcept {
|
void set_locale() noexcept {
|
||||||
const auto& locales = gucc::utils::make_multiline(gucc::utils::exec("cat /etc/locale.gen | grep -v \"# \" | sed 's/#//g' | awk '/UTF-8/ {print $1}'"));
|
const auto& locales = gucc::locale::get_possible_locales();
|
||||||
|
|
||||||
// System language
|
// System language
|
||||||
std::string locale{};
|
std::string locale{};
|
||||||
|
Loading…
Reference in New Issue
Block a user