mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-03 07:48:46 +08:00
Presist language user_preference
This commit is contained in:
parent
6011257c4b
commit
ae335df11e
@ -503,6 +503,7 @@ async function UIDesktop(options){
|
|||||||
// update local user preferences
|
// update local user preferences
|
||||||
const user_preferences = {
|
const user_preferences = {
|
||||||
show_hidden_files: (await puter.kv.get('user_preferences.show_hidden_files')) === 'true',
|
show_hidden_files: (await puter.kv.get('user_preferences.show_hidden_files')) === 'true',
|
||||||
|
language: (await puter.kv.get('user_preferences.language'))
|
||||||
};
|
};
|
||||||
update_user_preferences(user_preferences);
|
update_user_preferences(user_preferences);
|
||||||
|
|
||||||
|
@ -722,6 +722,7 @@ window.mutate_user_preferences = function(user_preferences_delta) {
|
|||||||
window.update_user_preferences = function(user_preferences) {
|
window.update_user_preferences = function(user_preferences) {
|
||||||
window.user_preferences = user_preferences;
|
window.user_preferences = user_preferences;
|
||||||
localStorage.setItem('user_preferences', JSON.stringify(user_preferences));
|
localStorage.setItem('user_preferences', JSON.stringify(user_preferences));
|
||||||
|
window.locale = user_preferences.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.sendWindowWillCloseMsg = function(iframe_element) {
|
window.sendWindowWillCloseMsg = function(iframe_element) {
|
||||||
|
@ -10,11 +10,8 @@ window.i18n = function (key, replacements = [], encode_html = true) {
|
|||||||
replacements = [replacements];
|
replacements = [replacements];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if locale is not set, default to en
|
let language = translations[window.locale] ?? translations['en'];
|
||||||
if(!translations[window.locale])
|
let str = language.dictionary[key] ?? translations['en'].dictionary[key];
|
||||||
window.locale = 'en';
|
|
||||||
|
|
||||||
let str = translations[window.locale].dictionary[key];
|
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
str = key;
|
str = key;
|
||||||
|
@ -46,9 +46,6 @@ window.initgui = async function(){
|
|||||||
if(window.api_origin && puter.APIOrigin !== window.api_origin)
|
if(window.api_origin && puter.APIOrigin !== window.api_origin)
|
||||||
puter.setAPIOrigin(api_origin);
|
puter.setAPIOrigin(api_origin);
|
||||||
|
|
||||||
// determine locale
|
|
||||||
window.locale = window.user_preferences.language;
|
|
||||||
|
|
||||||
// Checks the type of device the user is on (phone, tablet, or desktop).
|
// Checks the type of device the user is on (phone, tablet, or desktop).
|
||||||
// Depending on the device type, it sets a class attribute on the body tag
|
// Depending on the device type, it sets a class attribute on the body tag
|
||||||
// to style or script the page differently for each device type.
|
// to style or script the page differently for each device type.
|
||||||
|
Loading…
Reference in New Issue
Block a user