From df5e03a827d1534c0aa11ec353e8c2df352019f0 Mon Sep 17 00:00:00 2001
From: Ibnu Maksum <ibnumaksum@gmail.com>
Date: Mon, 19 Aug 2024 14:58:52 +0700
Subject: [PATCH] add user_language to attributes

---
 init.php                        | 5 +++++
 system/controllers/accounts.php | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/init.php b/init.php
index d3da03d8..0a875ba9 100644
--- a/init.php
+++ b/init.php
@@ -136,6 +136,11 @@ if (!empty($_SESSION['user_language'])) {
     $config['language'] = $_SESSION['user_language'];
 }else if (!empty($_COOKIE['user_language'])) {
     $config['language'] = $_COOKIE['user_language'];
+}else if(User::getID()>0){
+    $lang = User::getAttribute("Language");
+    if(!empty($lang)){
+        $config['language'] = $lang;
+    }
 }
 
 if (empty($_SESSION['Lang'])) {
diff --git a/system/controllers/accounts.php b/system/controllers/accounts.php
index 4fb44e3d..5a1e4726 100644
--- a/system/controllers/accounts.php
+++ b/system/controllers/accounts.php
@@ -328,7 +328,7 @@ switch ($action) {
             $_SESSION['Lang'] = $_L;
             file_put_contents($lan_file, json_encode($_L));
         }
-
+        User::setAttribute("Language", $selected_language);
         r2($_SERVER['HTTP_REFERER'], 's', ucwords($selected_language));