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`
GROUP BY `country`
ORDER BY COUNT(`country`) DESC
LIMIT 20';
LIMIT 10';
$countries = $this->connection->fetchAll($stmt);
$vars = [
'title' => 'Popular Countries',
'countries' => $countries
];

View file

@ -24,11 +24,10 @@ class PopularTags
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);
$vars = [
'title' => 'Popular 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="col-xl-9 col-lg-8">
<?php echo $this->fetch('sub/profiles.phtml', [
@ -14,6 +11,7 @@
<div class="col-xl-3 col-lg-4">
<?php echo $popularTags ?>
<?php echo $popularCountries ?>
<?php echo $popularLanguages ?>
</div>
</div>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<?php echo $lang?>">
<head>
<title>Friendica Directory</title>
<title><?php echo $this->__('Friendica Directory')?></title>
<base href="<?php echo $baseUrl ?>">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@ -15,22 +15,22 @@
<div class="container">
<a class="navbar-brand" href="">
<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>
<?php if (empty($noNavSearch)): ?>
<form class="form-inline my-2 my-lg-0 d-none d-md-flex" action="search">
<div class="input-group">
<label class="sr-only" for="header_search">Search terms</label>
<input name="q" class="form-control" type="search" id="header_search" placeholder="Search..."
aria-label="Search terms">
<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="<?php echo $this->p__('noun', 'Search')?>..."
aria-label="<?php echo $this->__('Search terms')?>">
<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>
</form>
<?php endif; ?>
<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>
</button>
@ -40,11 +40,11 @@
<li class="nav-item d-md-none">
<form action="search">
<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"
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">
<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>
</form>
@ -52,14 +52,29 @@
<?php endif; ?>
<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>-->
</a>
</li>
<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>
</ul>
</div>
</div>
</nav>

View file

@ -1,16 +1,22 @@
<!--<h1>Search</h1>-->
<form action="search">
<div class="input-group">
<label class="sr-only" for="search_search">Search terms</label>
<input name="q" class="form-control" type="search" id="search_search" placeholder="Search..."
aria-label="Search terms" value="<?php echo $this->escapeHtmlAttr($query) ?>">
<label class="sr-only" for="search_search"><?php echo $this->__('Search terms')?></label>
<?php if ($field):?>
<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">
<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>
</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', [
'page' => 'search',
'profiles' => $profiles,

View file

@ -1,5 +1,5 @@
<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) ?>
</nav>
<div class="row">
@ -9,6 +9,6 @@
</div>
<?php endforeach; ?>
</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) ?>
</nav>

View file

@ -1,56 +1,74 @@
<?php
$parts = [];
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'])
&& 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'])) {
$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">
<div class="media">
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>"><img class="mr-3 rounded"
src="photo/<?php echo $profile['id'] ?>.jpg"></a>
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
<img class="mr-3 rounded" src="photo/<?php echo $profile['id'] ?>.jpg">
</a>
<div class="media-body">
<h5 class="name">
<?php if ($profile['dfrn_request']): ?>
<a href="<?php echo $profile['dfrn_request']; ?>" class="card-link btn btn-primary float-right"><i
class="fa fa-external-link-alt"></i> Follow</a>
<a href="<?php echo $profile['dfrn_request']; ?>" class="card-link btn btn-primary float-right">
<i class="fa fa-external-link-alt"></i> <?php echo $this->p__('verb', 'Follow')?>
</a>
<?php endif; ?>
<?php echo $this->escapeHtml($profile['name']) ?>
</h5>
<p class="url"><a
href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>"><?php echo $this->escapeHtml($profile['addr']) ?></a>
<p class="url">
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
<?php echo $this->escapeHtml($profile['addr']) ?>
</a>
</p>
<p class="description d-none d-md-block"><?php echo $this->escapeHtml($profile['pdesc']) ?></p>
</div>
</div>
<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">
<?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 endif ?>
</div>
<?php if ($profile['tags']): ?>
<div class="tags">
<?php
$tags = array_map('trim', explode(' ', $profile['tags']));
foreach ($tags as $tag):?>
<span class="badge"><?php echo $this->escapeHtml($tag) ?> <a
href="/search?q=<?php echo $this->escapeUrl($tag) ?>"><i class="fa fa-tag"
title="Search tag"></i></a></span>
<span class="badge">
<?php echo $this->escapeHtml($tag) ?>
<a href="/search?q=<?php echo $this->escapeUrl($tag) ?>">
<i class="fa fa-tag" title="<?php echo $this->__('Search Tag')?>"></i>
</a>
</span>
<?php endforeach; ?>
</div>
<?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 ?>
</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) ?>
</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) ?>
</nav>
<?php foreach ($profiles as $profile) : ?>
<?php echo $this->fetch('sub/profile.phtml', ['profile' => $profile]) ?>
<?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) ?>
</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) ?>
</nav>

View file

@ -12,11 +12,11 @@ if ($server['health_score'] <= 0) {
}
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) {
$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 {
$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'];
@ -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>
</h6>
<p class="card-text">
<span class="badge <?php echo $badge_class ?>"><i
class="fa fa-heartbeat"></i> <?php echo $server['health_score'] ?></span>
<span class="badge badge-secondary"><i
class="fa fa-user"></i> <?php echo $this->e($server['user_count'] ?: '~'); ?> Users</span>
<span class="badge <?php echo $badge_class ?>">
<i class="fa fa-heartbeat"></i> <?php echo $server['health_score'] ?>
</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 if ($server['admin_profile'] && $server['admin_name']): ?>
<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']); ?>
</a>
<?php endif; ?>
<?php if ($server['admin_profile'] && $server['admin_name']): ?>
<a href="<?php echo $server['admin_profile']; ?>" class="badge badge-primary">
<i class="fa fa-star"></i> <?php echo $this->__('Admin')?>: <?php echo $this->e($server['admin_name']); ?>
</a>
<?php endif; ?>
</p>
<?php if ($server['info']) : ?>
<p class="card-text"><?php echo $this->e($server['info']); ?></p>
<?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; ?>
<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>
<?php /*

View file

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

View file

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