1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

feat: RTL Support for RTL Languages (Hebrew, Arabic) (#2832)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions

* add language direction to locale generation

* apply language direction when setting language

---------

Co-authored-by: boc-the-git <3479092+boc-the-git@users.noreply.github.com>
This commit is contained in:
Michael Genson 2024-01-19 10:56:36 -06:00 committed by GitHub
parent d17e46ee50
commit 10ba4d2d7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 110 additions and 37 deletions

View file

@ -4,14 +4,31 @@ import { LOCALES } from "./available-locales";
export const useLocales = () => {
const { i18n, $vuetify } = useContext();
function getLocale(value: string) {
const currentLocale = LOCALES.filter((locale) => locale.value === value);
return currentLocale.length ? currentLocale[0] : null;
}
const locale = computed<string>({
get() {
$vuetify.lang.current = i18n.locale; // dirty hack
// dirty hack
$vuetify.lang.current = i18n.locale;
const currentLocale = getLocale(i18n.locale);
if (currentLocale) {
$vuetify.rtl = currentLocale.dir === "rtl";
}
return i18n.locale;
},
set(value) {
i18n.setLocale(value);
$vuetify.lang.current = value; // this does not persist after window reload :-(
// this does not persist after window reload :-(
$vuetify.lang.current = value;
const currentLocale = getLocale(value);
if (currentLocale) {
$vuetify.rtl = currentLocale.dir === "rtl";
}
// Reload the page to update the language - not all strings are reactive
window.location.reload();