From a5749a5d8d38b0db2ce5548473f8a61b674578a6 Mon Sep 17 00:00:00 2001 From: namilsk Date: Sat, 31 Jan 2026 21:26:26 +0300 Subject: Started writing service-utils and adding docstrings --- init/src/host/locale.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'init/src/host/locale.rs') diff --git a/init/src/host/locale.rs b/init/src/host/locale.rs index 6dc43b2..d955297 100644 --- a/init/src/host/locale.rs +++ b/init/src/host/locale.rs @@ -1,9 +1,22 @@ +// NOTE: Ts file contains setting localisation by environment variables +// Main logic implemented but how i think it can contain with broken logic or checks +// At least if check failed it set C.UTF8 (fallback locale) +// And why is std::env::set_var unsafe???? + use crate::host::timezone::set_timezone; use crate::log::{log_success, log_warning}; use std::fs; use std::io::Write; use std::process::Command; +/// Main function which setting system locale. +/// +/// Logic && Checks +/// 1. Reading /etc/default/locale to find needed language. +/// If it broken/has syntax errors skipping this step +/// 2. Checking for locale avalible (also switching `-` and `_`), +/// if not uses fallback locale. +/// pub fn set_locale(locale: Option) -> Result<(), Box> { let loc = match locale { Some(l) => l, @@ -23,10 +36,10 @@ pub fn set_locale(locale: Option) -> Result<(), Box