Add translation string to templates

- Lower popular widget lists to 10 elements
- Add language to profile and server display
This commit is contained in:
Hypolite Petovan 2018-11-16 00:00:03 -05:00
parent 5b7bb030de
commit ff9eab39a7
11 changed files with 108 additions and 65 deletions

View file

@ -31,11 +31,10 @@ WHERE `country` != ""
AND `available` AND `available`
GROUP BY `country` GROUP BY `country`
ORDER BY COUNT(`country`) DESC ORDER BY COUNT(`country`) DESC
LIMIT 20'; LIMIT 10';
$countries = $this->connection->fetchAll($stmt); $countries = $this->connection->fetchAll($stmt);
$vars = [ $vars = [
'title' => 'Popular Countries',
'countries' => $countries 'countries' => $countries
]; ];

View file

@ -24,11 +24,10 @@ class PopularTags
public function render(): string public function render(): string
{ {
$stmt = 'SELECT `term`, COUNT(*) AS `total` FROM `tag` GROUP BY `term` ORDER BY COUNT(`term`) DESC LIMIT 20'; $stmt = 'SELECT `term`, COUNT(*) AS `total` FROM `tag` GROUP BY `term` ORDER BY COUNT(`term`) DESC LIMIT 10';
$tags = $this->connection->fetchAll($stmt); $tags = $this->connection->fetchAll($stmt);
$vars = [ $vars = [
'title' => 'Popular Tags',
'tags' => $tags 'tags' => $tags
]; ];

View file

@ -1,6 +1,3 @@
<!-- <div class="row">
<h1><?php echo $this->e($title) ?></h1>
</div>-->
<div class="row"> <div class="row">
<div class="col-xl-9 col-lg-8"> <div class="col-xl-9 col-lg-8">
<?php echo $this->fetch('sub/profiles.phtml', [ <?php echo $this->fetch('sub/profiles.phtml', [
@ -14,6 +11,7 @@
<div class="col-xl-3 col-lg-4"> <div class="col-xl-3 col-lg-4">
<?php echo $popularTags ?> <?php echo $popularTags ?>
<?php echo $popularCountries ?> <?php echo $popularCountries ?>
<?php echo $popularLanguages ?>
</div> </div>
</div> </div>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="<?php echo $lang?>">
<head> <head>
<title>Friendica Directory</title> <title><?php echo $this->__('Friendica Directory')?></title>
<base href="<?php echo $baseUrl ?>"> <base href="<?php echo $baseUrl ?>">
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@ -15,22 +15,22 @@
<div class="container"> <div class="container">
<a class="navbar-brand" href=""> <a class="navbar-brand" href="">
<img src="assets/images/friendica-32.png" width="32" height="32" class="d-inline-block align-top" alt=""> <img src="assets/images/friendica-32.png" width="32" height="32" class="d-inline-block align-top" alt="">
Friendica Directory <?php echo $this->__('Friendica Directory')?>
</a> </a>
<?php if (empty($noNavSearch)): ?> <?php if (empty($noNavSearch)): ?>
<form class="form-inline my-2 my-lg-0 d-none d-md-flex" action="search"> <form class="form-inline my-2 my-lg-0 d-none d-md-flex" action="search">
<div class="input-group"> <div class="input-group">
<label class="sr-only" for="header_search">Search terms</label> <label class="sr-only" for="header_search"><?php echo $this->__('Search terms')?></label>
<input name="q" class="form-control" type="search" id="header_search" placeholder="Search..." <input name="q" class="form-control" type="search" id="header_search" placeholder="<?php echo $this->p__('noun', 'Search')?>..."
aria-label="Search terms"> aria-label="<?php echo $this->__('Search terms')?>">
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-primary" type="submit">Search</button> <button class="btn btn-primary" type="submit"><?php echo $this->p__('verb', 'Search')?></button>
</div> </div>
</div> </div>
</form> </form>
<?php endif; ?> <?php endif; ?>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> aria-controls="navbarResponsive" aria-expanded="false" aria-label="<?php echo $this->__('Toggle navigation')?>">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -40,11 +40,11 @@
<li class="nav-item d-md-none"> <li class="nav-item d-md-none">
<form action="search"> <form action="search">
<div class="input-group"> <div class="input-group">
<label class="sr-only" for="nav_search">Search terms</label> <label class="sr-only" for="nav_search"><?php echo $this->__('Search terms')?></label>
<input name="q" class="form-control form-control-sm" type="search" id="nav_search" <input name="q" class="form-control form-control-sm" type="search" id="nav_search"
placeholder="Search..." aria-label="Search terms"> placeholder="<?php echo $this->p__('noun', 'Search')?>..." aria-label="<?php echo $this->__('Search terms')?>">
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-primary btn-sm" type="submit">Search</button> <button class="btn btn-primary btn-sm" type="submit"><?php echo $this->p__('verb', 'Search')?></button>
</div> </div>
</div> </div>
</form> </form>
@ -52,14 +52,29 @@
<?php endif; ?> <?php endif; ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-address-card"></i> Directory <a class="nav-link" href=""><i class="fa fa-address-card"></i> <?php echo $this->__('Directory')?>
<!--<span class="sr-only">(current)</span>--> <!--<span class="sr-only">(current)</span>-->
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="servers"><i class="fa fa-hotel"></i> Public Servers</a> <a class="nav-link" href="servers"><i class="fa fa-hotel"></i> <?php echo $this->__('Public servers')?></a>
</li>
<li class="nav-item">
<div class="dropdown">
<button class="btn btn-link nav-link dropdown-toggle" type="button" id="languageDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-language"></i> Language
</button>
<div class="dropdown-menu" aria-labelledby="languageDropdown">
<?php foreach($languages as $lang):?>
<a class="dropdown-item" href="?lang=<?php echo $this->escapeUrl($lang)?>">
<?php echo $this->e(Friendica\Directory\Utils\L10n::langToString($lang)) ?>
</a>
<?php endforeach;?>
</div>
</div>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</nav> </nav>

View file

@ -1,16 +1,22 @@
<!--<h1>Search</h1>--> <!--<h1>Search</h1>-->
<form action="search"> <form action="search">
<div class="input-group"> <div class="input-group">
<label class="sr-only" for="search_search">Search terms</label> <label class="sr-only" for="search_search"><?php echo $this->__('Search terms')?></label>
<input name="q" class="form-control" type="search" id="search_search" placeholder="Search..." <?php if ($field):?>
aria-label="Search terms" value="<?php echo $this->escapeHtmlAttr($query) ?>"> <input name="field" type="hidden" value="<?php echo $this->escapeHtmlAttr($field)?>"/>
<div class="input-group-prepend">
<span class="input-group-text"><?php echo $this->e($fieldName)?></span>
</div>
<?php endif;?>
<input name="q" class="form-control" type="search" id="search_search" placeholder="<?php echo $this->p__('noun', 'Search')?>..."
aria-label="<?php echo $this->__('Search terms')?>" value="<?php echo $this->escapeHtmlAttr($query) ?>">
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-primary" type="submit">Search</button> <button class="btn btn-primary" type="submit"><?php echo $this->p__('verb', 'Search')?></button>
</div> </div>
</div> </div>
</form> </form>
<h2><?php echo $count ?> results for "<?php echo $this->e($query) ?>"</h2> <h2><?php echo $this->n__('%d result for "%s"', '%d results for "%s"', intval($count), $this->e($query))?></h2>
<?php echo $this->fetch('sub/profiles.phtml', [ <?php echo $this->fetch('sub/profiles.phtml', [
'page' => 'search', 'page' => 'search',
'profiles' => $profiles, 'profiles' => $profiles,

View file

@ -1,5 +1,5 @@
<h1><?php echo $this->e($title) ?></h1> <h1><?php echo $this->e($title) ?></h1>
<nav aria-label="Top servers pagination"> <nav aria-label="<?php echo $this->__('Top servers pagination')?>">
<?php echo $this->fetch('sub/pager_full.phtml', $pager) ?> <?php echo $this->fetch('sub/pager_full.phtml', $pager) ?>
</nav> </nav>
<div class="row"> <div class="row">
@ -9,6 +9,6 @@
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<nav aria-label="Bottom servers pagination"> <nav aria-label="<?php echo $this->__('Bottom servers pagination')?>">
<?php echo $this->fetch('sub/pager_full.phtml', $pager) ?> <?php echo $this->fetch('sub/pager_full.phtml', $pager) ?>
</nav> </nav>

View file

@ -1,56 +1,74 @@
<?php <?php
$parts = []; $parts = [];
if (!empty($profile['locality'])) { if (!empty($profile['locality'])) {
$parts[] = $this->escapeHtml($profile['locality']) . ' <a href="search?field=locality&q=' . $this->escapeUrl($profile['locality']) . '"><span class="fa fa-filter" title="Search" aria-hidden="true"></span></a>'; $parts[] = $this->escapeHtml($profile['locality']) . ' <a href="search?field=locality&q=' . $this->escapeUrl($profile['locality']) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by locality') . '" aria-hidden="true"></span>
</a>';
} }
if (!empty($profile['region']) if (!empty($profile['region'])
&& strtolower($profile['locality']) != strtolower($profile['region'])) { && strtolower($profile['locality']) != strtolower($profile['region'])) {
$parts[] = $this->escapeHtml($profile['region']) . ' <a href="search?field=region&q=' . $this->escapeUrl($profile['region']) . '"><span class="fa fa-filter" title="Search" aria-hidden="true"></span></a>'; $parts[] = $this->escapeHtml($profile['region']) . ' <a href="search?field=region&q=' . $this->escapeUrl($profile['region']) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by region') . '" aria-hidden="true"></span>
</a>';
} }
if (!empty($profile['country'])) { if (!empty($profile['country'])) {
$parts[] = $this->escapeHtml($profile['country']) . ' <a href="search?field=country&q=' . $this->escapeUrl($profile['country']) . '"><span class="fa fa-filter" title="Search" aria-hidden="true"></span></a>'; $parts[] = $this->escapeHtml($profile['country']) . ' <a href="search?field=country&q=' . $this->escapeUrl($profile['country']) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by country') . '" aria-hidden="true"></span>
</a>';
} }
?> ?>
<figure id="profile-<?php echo $this->escapeHtmlAttr($profile['id']) ?>" class="bg-light p-3 rounded"> <figure id="profile-<?php echo $this->escapeHtmlAttr($profile['id']) ?>" class="bg-light p-3 rounded">
<div class="media"> <div class="media">
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>"><img class="mr-3 rounded" <a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
src="photo/<?php echo $profile['id'] ?>.jpg"></a> <img class="mr-3 rounded" src="photo/<?php echo $profile['id'] ?>.jpg">
</a>
<div class="media-body"> <div class="media-body">
<h5 class="name"> <h5 class="name">
<?php if ($profile['dfrn_request']): ?> <?php if ($profile['dfrn_request']): ?>
<a href="<?php echo $profile['dfrn_request']; ?>" class="card-link btn btn-primary float-right"><i <a href="<?php echo $profile['dfrn_request']; ?>" class="card-link btn btn-primary float-right">
class="fa fa-external-link-alt"></i> Follow</a> <i class="fa fa-external-link-alt"></i> <?php echo $this->p__('verb', 'Follow')?>
</a>
<?php endif; ?> <?php endif; ?>
<?php echo $this->escapeHtml($profile['name']) ?> <?php echo $this->escapeHtml($profile['name']) ?>
</h5> </h5>
<p class="url"><a <p class="url">
href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>"><?php echo $this->escapeHtml($profile['addr']) ?></a> <a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
<?php echo $this->escapeHtml($profile['addr']) ?>
</a>
</p> </p>
<p class="description d-none d-md-block"><?php echo $this->escapeHtml($profile['pdesc']) ?></p> <p class="description d-none d-md-block"><?php echo $this->escapeHtml($profile['pdesc']) ?></p>
</div> </div>
</div> </div>
<p class="description d-md-none"><?php echo $this->escapeHtml($profile['pdesc']) ?></p> <p class="description d-md-none"><?php echo $this->escapeHtml($profile['pdesc']) ?></p>
<?php if ($profile['language']):?>
<div class="language">
<i class="fa fa-language" alt="<?php echo $this->__('Language')?>" title="<?php echo $this->__('Language')?>"></i>
<?php echo $this->e(Friendica\Directory\Utils\L10n::langToString($profile['language'])) ?>
<a href="/search?field=language&amp;q=<?php echo $this->escapeUrl($profile['language']) ?>">
<i class="fa fa-filter" title="<?php echo $this->__('Filter by language')?>"></i>
</a>
</div>
<?php endif;?>
<div class="location"> <div class="location">
<?php if (count($parts)): ?> <?php if (count($parts)): ?>
<i class="fa fa-globe"></i> <i class="fa fa-globe" alt="<?php echo $this->__('Location')?>" title="<?php echo $this->__('Location')?>"></i>
<?php echo implode(', ', $parts); ?> <?php echo implode(', ', $parts); ?>
<?php endif ?> <?php endif ?>
</div> </div>
<?php if ($profile['tags']): ?> <?php if ($profile['tags']): ?>
<div class="tags"> <div class="tags">
<?php <?php
$tags = array_map('trim', explode(' ', $profile['tags'])); $tags = array_map('trim', explode(' ', $profile['tags']));
foreach ($tags as $tag):?> foreach ($tags as $tag):?>
<span class="badge">
<span class="badge"><?php echo $this->escapeHtml($tag) ?> <a <?php echo $this->escapeHtml($tag) ?>
href="/search?q=<?php echo $this->escapeUrl($tag) ?>"><i class="fa fa-tag" <a href="/search?q=<?php echo $this->escapeUrl($tag) ?>">
title="Search tag"></i></a></span> <i class="fa fa-tag" title="<?php echo $this->__('Search Tag')?>"></i>
</a>
</span>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>

View file

@ -1,18 +1,18 @@
<nav aria-label="Account type tabs" class="mb-3"> <nav aria-label="<?php echo $this->__('Account type tabs')?>" class="mb-3">
<?php echo $accountTypeTabs ?> <?php echo $accountTypeTabs ?>
</nav> </nav>
<nav aria-label="Top <?php echo $page ?> pagination" class="d-none d-md-block"> <nav aria-label="<?php echo $this->__('Top %s pagination', $page)?>" class="d-none d-md-block">
<?php echo $this->fetch('sub/pager_full.phtml', $pager_full) ?> <?php echo $this->fetch('sub/pager_full.phtml', $pager_full) ?>
</nav> </nav>
<nav aria-label="Top <?php echo $page ?> pagination" class="d-md-none"> <nav aria-label="<?php echo $this->__('Top %s pagination', $page)?>" class="d-md-none">
<?php echo $this->fetch('sub/pager_minimal.phtml', $pager_minimal) ?> <?php echo $this->fetch('sub/pager_minimal.phtml', $pager_minimal) ?>
</nav> </nav>
<?php foreach ($profiles as $profile) : ?> <?php foreach ($profiles as $profile) : ?>
<?php echo $this->fetch('sub/profile.phtml', ['profile' => $profile]) ?> <?php echo $this->fetch('sub/profile.phtml', ['profile' => $profile]) ?>
<?php endforeach; ?> <?php endforeach; ?>
<nav aria-label="Bottom <?php echo $page ?> pagination" class="d-none d-md-block"> <nav aria-label="<?php echo $this->__('Bottom %s pagination', $page)?>" class="d-none d-md-block">
<?php echo $this->fetch('sub/pager_full.phtml', $pager_full) ?> <?php echo $this->fetch('sub/pager_full.phtml', $pager_full) ?>
</nav> </nav>
<nav aria-label="Bottom <?php echo $page ?> pagination" class="d-md-none"> <nav aria-label="<?php echo $this->__('Bottom %s pagination', $page)?>" class="d-md-none">
<?php echo $this->fetch('sub/pager_minimal.phtml', $pager_minimal) ?> <?php echo $this->fetch('sub/pager_minimal.phtml', $pager_minimal) ?>
</nav> </nav>

View file

@ -12,11 +12,11 @@ if ($server['health_score'] <= 0) {
} }
if ($server['version'] == $stable_version) { if ($server['version'] == $stable_version) {
$version_badge = '<span class="badge badge-success"><i class="fa fa-smile"></i> Stable Version</span>'; $version_badge = '<span class="badge badge-success"><i class="fa fa-smile"></i> ' . $this->__('Stable Version') . '</span>';
} elseif ($server['version'] == $dev_version) { } elseif ($server['version'] == $dev_version) {
$version_badge = '<span class="badge badge-secondary"><i class="fa fa-poo"></i> Develop Version</span>'; $version_badge = '<span class="badge badge-secondary"><i class="fa fa-poo"></i> ' . $this->__('Develop Version') . '</span>';
} else { } else {
$version_badge = '<span class="badge badge-warning"><i class="fa fa-frown"></i> Outdated Version</span>'; $version_badge = '<span class="badge badge-warning"><i class="fa fa-frown"></i> ' . $this->__('Outdated Version') . '</span>';
} }
$base_url = $server['base_url']; $base_url = $server['base_url'];
@ -37,24 +37,32 @@ $base_url_display = substr($base_url, strpos($base_url, '/') + 2);
<a href="<?php echo $base_url; ?>"><?php echo $this->e($base_url_display); ?></a> <a href="<?php echo $base_url; ?>"><?php echo $this->e($base_url_display); ?></a>
</h6> </h6>
<p class="card-text"> <p class="card-text">
<span class="badge <?php echo $badge_class ?>"><i <span class="badge <?php echo $badge_class ?>">
class="fa fa-heartbeat"></i> <?php echo $server['health_score'] ?></span> <i class="fa fa-heartbeat"></i> <?php echo $server['health_score'] ?>
<span class="badge badge-secondary"><i </span>
class="fa fa-user"></i> <?php echo $this->e($server['user_count'] ?: '~'); ?> Users</span> <?php if ($server['language']):?>
<span class="badge badge-secondary" title="<?php echo $this->__('Default Language')?>">
<i class="fa fa-language" alt="<?php echo $this->__('Default Language')?>"></i>
<?php echo $this->e(Friendica\Directory\Utils\L10n::langToString($server['language'])) ?>
</span>
<?php endif;?>
<span class="badge badge-secondary" title="<?php echo $this->__('Known Users')?>">
<i class="fa fa-user"></i> <?php echo $this->e($server['user_count'] ?: '~'); ?> Users
</span>
<?php echo $version_badge; ?> <?php echo $version_badge; ?>
<?php if ($server['admin_profile'] && $server['admin_name']): ?> <?php if ($server['admin_profile'] && $server['admin_name']): ?>
<a href="<?php echo $server['admin_profile']; ?>" class="badge badge-primary"> <a href="<?php echo $server['admin_profile']; ?>" class="badge badge-primary">
<i class="fa fa-star"></i> Admin: <?php echo $this->e($server['admin_name']); ?> <i class="fa fa-star"></i> <?php echo $this->__('Admin')?>: <?php echo $this->e($server['admin_name']); ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
</p> </p>
<?php if ($server['info']) : ?> <?php if ($server['info']) : ?>
<p class="card-text"><?php echo $this->e($server['info']); ?></p> <p class="card-text"><?php echo $this->e($server['info']); ?></p>
<?php else: ?> <?php else: ?>
<p class="card-text text-muted">&lt;No description provided&gt;</p> <p class="card-text text-muted">&lt;<?php echo $this->__('No description provided')?>&gt;</p>
<?php endif; ?> <?php endif; ?>
<a href="<?php echo $base_url; ?>" class="card-link btn btn-primary"><i class="fa fa-external-link-alt"></i> <a href="<?php echo $base_url; ?>" class="card-link btn btn-primary"><i class="fa fa-external-link-alt"></i>
Visit server</a> <?php echo $this->__('Visit Server')?></a>
</div> </div>
</div> </div>
<?php /* <?php /*

View file

@ -1,5 +1,5 @@
<div> <div>
<h3><?php echo $this->e($title) ?></h3> <h3><?php echo $this->__('Popular Countries')?></h3>
<ul> <ul>
<?php foreach ($countries as $country): ?> <?php foreach ($countries as $country): ?>
<li> <li>

View file

@ -1,5 +1,5 @@
<div> <div>
<h3><?php echo $this->e($title) ?></h3> <h3><?php echo $this->__('Popular Tags')?></h3>
<ul> <ul>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li> <li>