Skip to content

Commit

Permalink
chore: add support for rtl languages
Browse files Browse the repository at this point in the history
  • Loading branch information
ellite committed May 18, 2024
1 parent 38a2ba9 commit ae99eef
Show file tree
Hide file tree
Showing 29 changed files with 220 additions and 121 deletions.
2 changes: 0 additions & 2 deletions .tmp/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img alt="Wallos" src="./images/siteicons/blue/wallos.png">
</picture>

Wallos: Open-Source Personal Subscription Tracker
Wallos: Open-Source Personal Subscription Trackers

## Table of Contents

Expand Down
36 changes: 36 additions & 0 deletions admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
require_once 'includes/header.php';

$settings = [];
$settings['registrations'] = false;
?>

<section class="contain settings">

<section class="account-section">
<header>
<h2><?= translate('backup_and_restore', $i18n) ?></h2>
</header>
<div class="form-group-inline">
<div>
<input type="button" class="button thin" value="<?= translate('backup', $i18n) ?>" id="backupDB" onClick="backupDB()"/>
</div>
<div>
<input type="button" class="secondary-button thin" value="<?= translate('restore', $i18n) ?>" id="restoreDB" onClick="openRestoreDBFileSelect()" />
<input type="file" name="restoreDBFile" id="restoreDBFile" style="display: none;" onChange="restoreDB()" accept=".zip">
</div>
</div>
<div class="settings-notes">
<p>
<i class="fa-solid fa-circle-info"></i>
<?= translate('restore_info', $i18n) ?>
</p>
</div>
</section>

</section>
<script src="scripts/admin.js?<?= $version ?>"></script>

<?php
require_once 'includes/footer.php';
?>
10 changes: 8 additions & 2 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
if (isset($settings['color_theme'])) {
$colorTheme = $settings['color_theme'];
}

$isAdmin = $_SESSION['userId'] == 1;

?>
<!DOCTYPE html>
<html>
<html dir="<?= $languages[$lang]['dir'] ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
Expand Down Expand Up @@ -76,7 +79,7 @@
<script type="text/javascript" src="scripts/i18n/<?= $lang ?>.js?<?= $version ?>"></script>
<script type="text/javascript" src="scripts/i18n/getlang.js?<?= $version ?>"></script>
</head>
<body class="<?= $theme ?>">
<body class="<?= $theme ?> <?= $languages[$lang]['dir'] ?>">
<header>
<div class="contain">
<div class="logo">
Expand All @@ -94,6 +97,9 @@
<a href="."><i class="fa-solid fa-list"></i><?= translate('subscriptions', $i18n) ?></a>
<a href="stats.php"><i class="fa-solid fa-chart-simple"></i><?= translate('stats', $i18n) ?></a>
<a href="settings.php"><i class="fa-solid fa-gear"></i><?= translate('settings', $i18n) ?></a>
<?php if ($isAdmin): ?>
<a href="admin.php"><i class="fa-solid fa-user-tie"></i><?= translate('admin', $i18n) ?></a>
<?php endif; ?>
<a href="about.php"><i class="fa-solid fa-info-circle"></i><?= translate('about', $i18n) ?></a>
<a href="logout.php"><i class="fa-solid fa-arrow-right-from-bracket"></i><?= translate('logout', $i18n) ?></a>
</div>
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Abonnements",
'stats' => "Statistiken",
'settings' => "Einstellungen",
'admin' => "Admin",
'about' => "Über",
'logout' => "Logout",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Συνδρομές",
'stats' => "Στατιστικές",
'settings' => "Ρυθμίσεις",
'admin' => "Διαχείριση",
'about' => "Για εμάς",
'logout' => "Αποσύνδεση",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Subscriptions",
'stats' => "Statistics",
'settings' => "Settings",
'admin' => "Admin",
'about' => "About",
'logout' => "Logout",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Suscripciones",
'stats' => "Estadísticas",
'settings' => "Configuración",
'admin' => "Admin",
'about' => "Acerca de",
'logout' => "Cerrar Sesión",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Abonnements",
'stats' => "Statistiques",
'settings' => "Paramètres",
'admin' => "Admin",
'about' => "À propos",
'logout' => "Déconnexion",
// Page d'abonnements
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'subscriptions' => 'Abbonamenti',
'stats' => 'Statistiche',
'settings' => 'Impostazioni',
'admin' => 'Amministrazione',
'about' => 'Informazioni',
'logout' => 'Esci',

Expand Down
1 change: 1 addition & 0 deletions includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "定期購入",
'stats' => "統計",
'settings' => "設定",
'admin' => "管理者",
'about' => "About",
'logout' => "ログアウト",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ko.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "구독",
'stats' => "통계",
'settings' => "설정",
'admin' => "관리자",
'about' => "정보",
'logout' => "로그아웃",
// Subscriptions page
Expand Down
41 changes: 20 additions & 21 deletions includes/i18n/languages.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<?php

// File Name => Language Name
// File Name => Language Name
$languages = [
// English first
"en" => "English",
"en" => ["name" => "English", "dir" => "ltr"],
// Remaining sorted alphabetically by language code
"de" => "Deutsch",
"el" => "Ελληνικά",
"es" => "Español",
"fr" => "Français",
"it" => "Italiano",
"jp" => "日本語",
"ko" => "한국어",
"pl" => "Polski",
"pt" => "Português",
"pt_br" => "Português Brasileiro",
"ru" => "Русский",
"sr_lat" => "Srpski",
"sr" => "Српски",
"tr" => "Türkçe",
"zh_cn" => "简体中文",
"zh_tw" => "繁體中文",
"de" => ["name" => "Deutsch", "dir" => "ltr"],
"el" => ["name" => "Ελληνικά", "dir" => "ltr"],
"es" => ["name" => "Español", "dir" => "ltr"],
"fr" => ["name" => "Français", "dir" => "ltr"],
"it" => ["name" => "Italiano", "dir" => "ltr"],
"jp" => ["name" => "日本語", "dir" => "ltr"],
"ko" => ["name" => "한국어", "dir" => "ltr"],
"pl" => ["name" => "Polski", "dir" => "ltr"],
"pt" => ["name" => "Português", "dir" => "ltr"],
"pt_br" => ["name" => "Português Brasileiro", "dir" => "ltr"],
"ru" => ["name" => "Русский", "dir" => "ltr"],
"sr_lat" => ["name" => "Srpski", "dir" => "ltr"],
"sr" => ["name" => "Српски", "dir" => "ltr"],
"tr" => ["name" => "Türkçe", "dir" => "ltr"],
"zh_cn" => ["name" => "简体中文", "dir" => "ltr"],
"zh_tw" => ["name" => "繁體中文", "dir" => "ltr"],
]

?>
?>
1 change: 1 addition & 0 deletions includes/i18n/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Subskrypcje",
'stats' => "Statystyki",
'settings' => "Ustawienia",
'admin' => "Admin",
'about' => "O aplikacji",
'logout' => "Wyloguj się",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Subscrições",
'stats' => "Estatísticas",
'settings' => "Definições",
'admin' => "Administração",
'about' => "Sobre",
'logout' => "Terminar Sessão",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt_br.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Assinaturas",
'stats' => "Estatísticas",
'settings' => "Configurações",
'admin' => "Admin",
'about' => "Sobre",
'logout' => "Sair",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Подписки",
'stats' => "Статистика",
'settings' => "Настройки",
'admin' => "Администратор",
'about' => "О программе",
'logout' => "Выйти",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Претплате",
'stats' => "Статистике",
'settings' => "Подешавања",
'admin' => "Админ",
'about' => "О апликацији",
'logout' => "Одјава",
// Страница са претплатама
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr_lat.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Pretplate",
'stats' => "Statistike",
'settings' => "Podešavanja",
'admin' => "Admin",
'about' => "O aplikaciji",
'logout' => "Odjava",
// Stranica sa pretplatama
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/tr.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "Abonelikler",
'stats' => "İstatistikler",
'settings' => "Ayarlar",
'admin' => "Yönetici",
'about' => "Hakkında",
'logout' => "Çıkış Yap",
// Subscriptions page
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'subscriptions' => "订阅",
'stats' => "统计",
'settings' => "设置",
'admin' => "管理员",
'about' => "关于",
'logout' => "登出",

Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_tw.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'subscriptions' => "訂閱",
'stats' => "統計",
'settings' => "設定",
'admin' => "管理員",
'about' => "關於",
'logout' => "登出",
// 訂閱頁面
Expand Down
4 changes: 2 additions & 2 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}
?>
<!DOCTYPE html>
<html>
<html dir="<?= $languages[$lang]['dir'] ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
Expand All @@ -94,7 +94,7 @@
<link rel="stylesheet" href="styles/barlow.css">
<link rel="stylesheet" href="styles/login-dark-theme.css?<?= $version ?>" id="dark-theme" <?= $theme == "light" ? "disabled" : "" ?>>
</head>
<body>
<body class="<?= $theme ?> <?= $languages[$lang]['dir'] ?>">
<div class="content">
<section class="container">
<header>
Expand Down
8 changes: 4 additions & 4 deletions registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function validate($value) {
}
?>
<!DOCTYPE html>
<html>
<html dir="<?= $languages[$lang]['dir'] ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
Expand All @@ -109,7 +109,7 @@ function validate($value) {
<link rel="stylesheet" href="styles/barlow.css">
<script type="text/javascript" src="scripts/registration.js?<?= $version ?>"></script>
</head>
<body>
<body class="<?= $theme ?> <?= $languages[$lang]['dir'] ?>">
<div class="content">
<section class="container">
<header>
Expand Down Expand Up @@ -157,10 +157,10 @@ function validate($value) {
<label for="language"><?= translate('language', $i18n) ?>:</label>
<select id="language" name="language" placeholder="Language" onchange="changeLanguage(this.value)">
<?php
foreach ($languages as $code => $name) {
foreach ($languages as $code => $language) {
$selected = ($code === $lang) ? 'selected' : '';
?>
<option value="<?= $code ?>" <?= $selected ?>><?= $name ?></option>
<option value="<?= $code ?>" <?= $selected ?>><?= $language['name'] ?></option>
<?php
}
?>
Expand Down
59 changes: 59 additions & 0 deletions scripts/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function backupDB() {
const button = document.getElementById("backupDB");
button.disabled = true;

fetch('endpoints/db/backup.php')
.then(response => response.json())
.then(data => {
if (data.success) {
const link = document.createElement('a');
const filename = data.file;
link.href = '.tmp/' + filename;
link.download = 'backup.zip';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

button.disabled = false;
} else {
showErrorMessage(data.errorMessage);
button.disabled = false;
}
})
.catch(error => {
showErrorMessage(error);
button.disabled = false;
});
}

function openRestoreDBFileSelect() {
document.getElementById('restoreDBFile').click();
};

function restoreDB() {
const input = document.getElementById('restoreDBFile');
const file = input.files[0];

if (!file) {
console.error('No file selected');
return;
}

const formData = new FormData();
formData.append('file', file);

fetch('endpoints/db/restore.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
showSuccessMessage(data.message)
window.location.href = 'logout.php';
} else {
showErrorMessage(data.message);
}
})
.catch(error => showErrorMessage('Error:', error));
}
Loading

0 comments on commit ae99eef

Please sign in to comment.