236{
237 const std::string lang_conf = Glib::get_home_dir() + "/.config/BastionGuard/lang.conf";
238 std::ifstream f(lang_conf);
239 if (!f.is_open())
240 return false;
241
243 bool any = false;
244
245 while (std::getline(f, line)) {
246 if (
line.empty() || line[0] ==
'#')
247 continue;
248
249 auto pos =
line.find(
'=');
250 if (pos == std::string::npos)
251 continue;
252
253 std::string key =
line.substr(0, pos);
254 std::string val =
line.substr(pos + 1);
255
256 auto ltrim = [](std::string& s){
257 s.erase(0, s.find_first_not_of(" \t\r\n"));
258 };
259 auto rtrim = [](std::string& s){
260 s.erase(s.find_last_not_of(" \t\r\n") + 1);
261 };
262 ltrim(key); rtrim(key);
263 ltrim(val); rtrim(val);
264
265 if (!key.empty() && !val.empty()) {
266 setenv(key.c_str(), val.c_str(), 1);
267 any = true;
268 }
269 }
270
271 return any;
272}