Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

locale: Fixed locale #39

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/functions/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ use crate::internal::*;

pub fn set_timezone(timezone: &str) {
exec_eval(
exec(
// Remember this should run in a chroot
// not on the host, as linking to /mnt/usr/share/zoneinfo
// will mean you're gonna have a bad time
exec_chroot(
"ln",
vec![
"-sf".to_string(),
format!("/mnt/usr/share/zoneinfo/{}", timezone),
"/mnt/etc/localtime".to_string(),
format!("/usr/share/zoneinfo/{}", timezone),
"/etc/localtime".to_string(),
],
),
"Set timezone",
Expand All @@ -21,20 +24,18 @@ pub fn set_timezone(timezone: &str) {

pub fn set_locale(locale: String) {
files_eval(
axtloss marked this conversation as resolved.
Show resolved Hide resolved
files::append_file("/mnt/etc/locale.gen", "en_US.UTF-8 UTF-8\n"),
files::append_file("/mnt/etc/locale.gen", "en_US.UTF-8 UTF-8"),
"add en_US.UTF-8 UTF-8 to locale.gen",
);
// TODO: Refactor this
for i in (0..locale.split(' ').count()).step_by(2) {
files_eval(
files::append_file(
"/mnt/etc/locale.gen",
format!(
&format!(
"{} {}\n",
locale.split(' ').collect::<Vec<&str>>()[i],
locale.split(' ').collect::<Vec<&str>>()[i + 1]
)
.as_str(),
),
),
"add locales to locale.gen",
);
Expand Down