Language switching, flags and some small tweaks

This commit is contained in:
Vojtěch Sajdl 2018-01-02 19:37:15 +01:00
parent dd250581d5
commit 333d6b40b8
No known key found for this signature in database
GPG Key ID: 5D4EB1361A272390
7 changed files with 52 additions and 15 deletions

View File

@ -16,10 +16,7 @@ class Constellation
{ {
$offset = 0; $offset = 0;
} }
if (isset($_GET['ajax'])) $ajax = isset($_GET['ajax']);
{
$ajax = true;
}
$limit++; $limit++;
$c = ($future)?">=":"<="; $c = ($future)?">=":"<=";
$timestamp = (isset($_GET['timestamp'])&& !$future)?$_GET['timestamp']:time(); $timestamp = (isset($_GET['timestamp'])&& !$future)?$_GET['timestamp']:time();

View File

@ -1,23 +1,42 @@
<?php <?php
function render_footer($admin = false) function render_footer($admin = false)
{?> {
global $best_match, $lang_names;
?>
</div> </div>
<div id="footerwrap"> <div id="footerwrap">
<div class="container"> <div class="container">
<div class="row centered"> <div class="row centered">
<div class="col-md-8">Copyright © <?php echo date("Y");?> Vojtěch Sajdl</div> <div class="col-md-4 text-left">Copyright © <?php echo date("Y");?> Vojtěch Sajdl</div>
<div class="col-md-4"><a href="https://github.com/Pryx/server-status/" target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a></div> <div class="col-md-4 text-center">
<div class="btn-group dropup">
<button type="button" class="btn btn-primary"><?php echo '<img src="'.WEB_URL.'/locale/'.$best_match.'/flag.png" alt="'.$lang_names[$best_match].'">'.$lang_names[$best_match];?></button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only"><?php echo _("Toggle Dropdown");?></span>
</button>
<ul class="dropdown-menu">
<?php
foreach ($lang_names as $key => $value) {
echo '<a href="?lang='.$key.'""><img src="'.WEB_URL.'/locale/'.$key.'/flag.png" alt="'.$value.'">'.$value.'</a>';
}
?>
</ul>
</div>
</div>
<div class="col-md-4 text-right"><a href="https://github.com/Pryx/server-status/" target="_blank"><i class="fa fa-github" aria-hidden="true"></i></a></div>
</div><!--/row --> </div><!--/row -->
</div><!--/container --> </div><!--/container -->
</div> </div>
<script src="/js/vendor/jquery-1.11.2.min.js"></script> <script src="/js/vendor/jquery-1.11.2.min.js"></script>
<script src="/js/vendor/jquery.timeago.js"></script> <script src="/js/vendor/jquery.timeago.js"></script>
<?php if ($admin){?> <?php if ($admin){?>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="/js/admin.js"></script> <script src="/js/admin.js"></script>
<script src="/js/vendor/jquery.growl.js"></script> <script src="/js/vendor/jquery.growl.js"></script>
<? }?> <? }?>
<script src="/js/main.js"></script> <script src="/js/vendor/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
</body> </body>
</html> </html>
<? <?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 15 KiB

7
js/vendor/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,11 @@
<?php <?php
function mb_ucfirst($string)
{
return mb_strtoupper(mb_substr($string, 0, 1)).mb_strtolower(mb_substr($string, 1));
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
@ -10,14 +16,18 @@ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
if ($val === '') $langs[$lang] = 1; if ($val === '') $langs[$lang] = 1;
} }
if (isset($_GET['lang']))
{
$langs[$_GET['lang']] = 2;
}
arsort($langs, SORT_NUMERIC); arsort($langs, SORT_NUMERIC);
} }
} }
$langs = array_flip($langs); $langs = array_flip($langs);
$accepted_langs = glob(__DIR__ . '/locale/*' , GLOB_ONLYDIR); $accepted_langs = glob(__DIR__ . '/locale/*' , GLOB_ONLYDIR);
$lang_names = array();
foreach ($accepted_langs as $key => $value) { foreach ($accepted_langs as $key => $value) {
$accepted_langs[$key] = basename($value); $accepted_langs[$key] = basename($value);
} }
@ -43,6 +53,10 @@ foreach ($langs as $lang) {
} }
} }
foreach ($accepted_langs as $lang) {
$lang_names[$lang] = mb_ucfirst(locale_get_display_language($lang, $lang));
}
if ($best_match === false){ if ($best_match === false){
$best_match = DEFAULT_LANGUAGE; $best_match = DEFAULT_LANGUAGE;
} }

BIN
locale/cs_CZ/flag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
locale/en_GB/flag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB