Skip to content

Commit

Permalink
Merge pull request #128 from SondreNjaastad/main
Browse files Browse the repository at this point in the history
Language makeover
  • Loading branch information
jelveh authored Mar 18, 2024
2 parents 37f5c7e + e628cef commit 85a7190
Show file tree
Hide file tree
Showing 22 changed files with 2,202 additions and 1,343 deletions.
26 changes: 24 additions & 2 deletions src/UI/UIDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import UIWindowQR from "./UIWindowQR.js"
import UIWindowRefer from "./UIWindowRefer.js"
import UITaskbar from "./UITaskbar.js"
import new_context_menu_item from "../helpers/new_context_menu_item.js"
import ChangeLanguage from "../i18n/i18nChangeLanguage.js"

async function UIDesktop(options){
let h = '';
Expand Down Expand Up @@ -1045,7 +1046,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){
if(window.user.is_temp){
items.push(
{
html: `Save Session`,
html: i18n('save_session'),
icon: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
icon_active: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
onClick: async function(){
Expand Down Expand Up @@ -1097,7 +1098,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){

items.push(
{
html: 'Add existing account',
html: i18n('add_existing_account'),
// icon: l_user.username === user.username ? '✓' : '',
onClick: async function(val){
await UIWindowLogin({
Expand All @@ -1118,6 +1119,19 @@ $(document).on('click', '.user-options-menu-btn', async function(e){

}

// -------------------------------------------
// Load avaialble languages
// -------------------------------------------
const supoprtedLanguagesItems = ListSupportedLanugages().map(lang => {
return {
html: lang.name,
icon: window.locale === lang.code ? '✓' : '',
onClick: async function(){
ChangeLanguage(lang.code);
}
}
});

UIContextMenu({
id: 'user-options-menu',
parent_element: parent_element,
Expand Down Expand Up @@ -1152,6 +1166,14 @@ $(document).on('click', '.user-options-menu-btn', async function(e){
UIWindowChangePassword();
}
},

//--------------------------------------------------
// Change Language
//--------------------------------------------------
{
html: i18n('change_language'),
items: supoprtedLanguagesItems
},
//--------------------------------------------------
// Contact Us
//--------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/UI/UIWindowLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function UIWindowLogin(options){
h += `<div class="generic-close-window-button"> &times; </div>`;
h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
// title
h += `<h1 class="login-form-title">Log In</h1>`;
h += `<h1 class="login-form-title">${i18n('log_in')}</h1>`;
// login form
h += `<form class="login-form">`;
// error msg
Expand Down
1 change: 1 addition & 0 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ try {
if (window.user_preferences === null) {
window.user_preferences = {
show_hidden_files: false,
language: navigator.language.split("-")[0] || navigator.userLanguage || 'en',
}
}

Expand Down
Loading

0 comments on commit 85a7190

Please sign in to comment.