oxen-io / session-desktop

Session Desktop - Onion routing based messenger
https://getsession.org
GNU General Public License v3.0
1.51k stars 192 forks source link

[Feature request] Option to change the UI's language. #1877

Open fightuntilwedie opened 3 years ago

fightuntilwedie commented 3 years ago

I am using Debian 11 and an unofficial LineageOS. Session App on both devices doesn't offer an option to change the UI's language. Would be great if it was implemented in future versions.

Bilb commented 3 years ago

Hey, on linux you can start the app with LANGUAGE=FR_fr yarn start-prod.

fightuntilwedie commented 3 years ago

Could you give me more information? I've got the AppImage in a folder on the desktop and a shortcut/starter in the shortcut bar.

Bilb commented 2 years ago

@fightuntilwedie sorry for the delay You would need to edit your shortcut to launch a script instead of the appimage directly.

Something like that should work

sudo gedit /usr/local/bin/session-desktop-localized.sh

Copy paste what's following in the opening window

#!/bin/bash

LANGUAGE=ru ~/Downloads/session-desktop-linux-x86_64-1.7.1.AppImage

In this same window edit the path to the appimage (here I used ~/Downloads/ but that's probably not your case) In this same window edit the language you want to start the app in (here I used ru for russian)

Then, allow execution for this script:

sudo chmod +x /usr/local/bin/session-desktop-localized.sh

Finally, edit the shortcut you have in your shortcut bar to start this script directly by giving its fullpath like so /usr/local/bin/session-desktop-localized.sh What would be the language you want the app in?

fightuntilwedie commented 2 years ago

Hi and thank you for your answer. In the meantime I solved the issue by simply switching the whole system's language to English US. Hence, Session did the same! ;))

KeeJef commented 1 year ago

I think it would be great to have a language setting under settings -> appearance, to force Session language to be different from the system language

Bilb commented 1 year ago

We could do that quite easily, but that would require a restart to take effect (localized strings are loaded on startup and not refresh after that)

KeeJef commented 1 year ago

Just waiting on UI designs to attach to this issue before this can be picked up

VityaSchel commented 4 months ago

Just waiting on UI designs to attach to this issue before this can be picked up

Does this looks good enough?

telegram-cloud-photo-size-2-5285362973679933974-y telegram-cloud-photo-size-2-5285362973679933982-y telegram-cloud-photo-size-2-5285362973679933983-x telegram-cloud-photo-size-2-5285362973679933984-x telegram-cloud-photo-size-2-5285362973679933985-x

I used native <select>, removed default arrow by setting background image to none, added my own arrow built with 0px border hack which has var(--input-border-color) as color. Added transitions to ensure colors are animated during theme change.

From the technical side, I wanted to use window.get/setSettingValue but it wasn't available on startup in mainnode.ts, so I used userConfig instead with ipc events to sync between frontend and backend. It stores current language code in config and falls back the same way app falls back (process.env.LANGUAGE || app.getLocale() || 'en'). Languages are stored as part before `character i.e. directory names in /_locales. Additionally, I'm usingapp.relaunch();andapp.exit();` to restart electron after changing language.

Languages in <select> are hardcoded and static, which means you have to edit this list each time new language is added or removed, because you need to write a language name anytime it's added anyway and I didn't want to spend time passing directory names into frontend, but I can patch this quickly if needed.

I can't create pull requests though, because I already forked this repository some time ago for https://github.com/VityaSchel/session-nodejs-bot and now it won't let me fork it second time 😅 I already submitted ticket to GitHub support, hopefully they'll be able to detach my bot framework into standalone repository tomorrow and then I'll create PR for review.

VityaSchel commented 4 months ago

GitHub still does not let me fork this repository, so I'll put patch file here with changes and then I'll create PR as soon as I'm able to fork.

0001-feat-add-option-to-change-UI-language.patch