DEV: Локализация

This commit is contained in:
Evg 2021-03-31 14:26:17 +03:00
parent c92f78a3e4
commit bbd58d5568
6 changed files with 55 additions and 59 deletions

View file

@ -1,17 +1 @@
<?php
define('L_LOGO', 'My');
define('L_HOME_NAME', 'AreaDev');
define('L_HOME', 'Home');
define('L_COMMENTS', 'Comments');
define('L_SPACE', 'Spaces');
define('L_TOP', 'TOP');
define('L_LOGOUT', 'Sign out');
define('L_ENTRY', 'Login');
define('L_REGISTRATION', 'Registration');
define('L_PROFILE', 'Profile');
define('L_SETTINGS', 'Settings');
define('L_MESSAGES', 'Messages');
define('L_MY_COMM', 'My answers');
define('L_FAVORITES', 'Favorites');
define('L_ADMIN', 'Admin panel');

View file

@ -1,17 +1,21 @@
<?php
define('L_LOGO', 'My');
define('L_HOME_NAME', 'AreaDev');
define('L_HOME', 'Главная');
define('L_COMMENTS', 'Комментарии');
define('L_SPACE', 'Пространства');
define('L_TOP', 'TOP');
define('L_LOGOUT', 'Выход');
define('L_ENTRY', 'Войти');
define('L_REGISTRATION', 'Регистрация');
define('L_PROFILE', 'Профиль');
define('L_SETTINGS', 'Настройки');
define('L_MESSAGES', 'Сообщения');
define('L_MY_COMM', 'Мои ответы');
define('L_FAVORITES', 'Избранное');
define('L_ADMIN', 'Админка');
<?php
return [
'My' => 'My',
'AreaDev' => 'AreaDev',
'Home' => 'Главная',
'TOP' => 'TOP',
'Space' => 'Пространства',
'Comments' => 'Комментарии',
'Sign in' => 'Войти',
'Sign out' => 'Выйти',
'Sign up' => 'Регистрация',
'Profile' => 'Профиль',
'Settings' => 'Настройки',
'Messages' => 'Сообщения',
'Favorites' => 'Избранное',
'Admin' => 'Админка',
'Help' => 'Помощь',
'Statistics' => 'Статистика',
'Privacy' => 'Конфедициальность',
'About' => 'О нас',
];

View file

@ -103,3 +103,11 @@ function public_path() {
function view_path() {
return hleb_601e30l60p2ii1e0o469tl_view_path();
}
// Локализация
function lang($text){
if(isset(LANG[$text])){
return LANG[$text];
}
return $text;
}

View file

@ -13,7 +13,7 @@ define('TEMPLATE_DIR', realpath(__DIR__ . '/../resources/views/'));
// Загружаем файл конфигурации и локализации
$GLOBALS['conf'] = include( __DIR__ .'/../config.inc.php');
require __DIR__ . '/../app/Language/'. $GLOBALS['conf']['lang'] .'/lang.php';
define('LANG', include_once(__DIR__ .'/../app/Language/'. $GLOBALS['conf']['lang']. '/lang.php'));
// General headers.
// Общие заголовки.

View file

@ -1,9 +1,9 @@
<div class="wrap">
<footer>
<a title="Помощь" href="/info">Помощь</a>
<a title="Статистика" href="/info/stats">Статистика</a>
<a class="no-mob" title="Конфиденциальность" href="/info/privacy">Конфиденциальность</a>
<a title="О нас" href="/info/about">О нас</a>
<a title="<?= lang('Help'); ?>" href="/info"><?= lang('Help'); ?></a>
<a title="<?= lang('Statistics'); ?>" href="/info/stats"><?= lang('Statistics'); ?></a>
<a class="no-mob" title="<?= lang('Privacy'); ?>" href="/info/privacy"><?= lang('Privacy'); ?></a>
<a title="<?= lang('About us'); ?>" href="/info/about"><?= lang('About'); ?></a>
</footer>
</div>
<script src="/assets/js/jquery.min.js"></script>
@ -13,4 +13,4 @@
<!--script src="/assets/js/editorjs@latest.js"></script-->
<?php } ?>
</body>
</html>
</html>

View file

@ -19,28 +19,28 @@
<header>
<div class="wrap">
<div class="title">
<a title="<?= L_HOME; ?>" class="logo" href="/"><?= L_LOGO; ?></a>
<a title="<?= lang('Home'); ?>" class="logo" href="/"><?= lang('My'); ?></a>
<div class="menu-left">
<ul>
<li class="nav no-mob">
<?php if(Request::getUri() == '/') { ?>
<a title="<?= L_HOME; ?>" class="home" href="/"><?= L_HOME_NAME; ?></a>
<a title="<?= lang('Home'); ?>" class="home" href="/"><?= lang('AreaDev'); ?></a>
<?php } else { ?>
<a title="<?= L_HOME; ?>" class="home" href="/"><?= L_HOME; ?></a>
<a title="<?= lang('Home'); ?>" class="home" href="/"><?= lang('Home'); ?></a>
<?php } ?>
</li>
<li class="nav no-mob<?php if(Request::getUri() == '/top') { ?> active<?php } ?>">
<a title="<?= L_TOP; ?>" class="home" href="/top">
<?= L_TOP; ?>
<a title="<?= lang('TOP'); ?>" class="home" href="/top">
<?= lang('TOP'); ?>
</a>
</li>
<li class="nav no-mob-two<?php if(Request::getUri() == '/comments') { ?> active<?php } ?>">
<a title="<?= L_COMMENTS; ?>" class="comments" href="/comments">
<?= L_COMMENTS; ?>
<a title="<?= lang('Comments'); ?>" class="comments" href="/comments">
<?= lang('Comments'); ?>
</a>
</li>
<li class="nav no-mob-two<?php if(Request::getUri() == '/space') { ?> active<?php } ?>">
<a title="<?= L_SPACE; ?>" class="sp" href="/space">~</a>
<a title="<?= lang('Space'); ?>" class="sp" href="/space">~</a>
</li>
</ul>
</div>
@ -54,12 +54,12 @@
</svg>
</span>
</li>
<?php if(!$uid['id']) { ?>
<?php if(!$uid['id']) { ?>
<li class="nav">
<a class="login" title="<?= L_ENTRY; ?>" href="/login"><?= L_ENTRY; ?></a>
<a class="login" title="<?= lang('Sign in'); ?>" href="/login"><?= lang('Sign in'); ?></a>
</li>
<li class="nav">
<a class="register" title="<?= L_REGISTRATION; ?>" href="/register"><?= L_REGISTRATION; ?></a>
<a class="register" title="<?= lang('Sign up'); ?>" href="/register"><?= lang('Sign up'); ?></a>
</li>
<?php } else { ?>
<li class="nav create">
@ -91,46 +91,46 @@
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#user"></use>
</svg>
<?= L_PROFILE; ?>
<?= lang('Profile'); ?>
</a>
<a href="/users/setting">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#settings"></use>
</svg>
<?= L_SETTINGS; ?>
<?= lang('Settings'); ?>
</a>
<a href="/messages">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#mail"></use>
</svg>
<?= L_MESSAGES; ?>
<?= lang('Messages'); ?>
</a>
<a href="/threads/<?= $uid['login']; ?>">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#devices"></use>
<use xlink:href="/assets/svg/icons.svg#message"></use>
</svg>
<?= L_MY_COMM; ?>
<?= lang('Comments'); ?>
</a>
<a href="/favorite/<?= $uid['login']; ?>">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#bookmark"></use>
</svg>
<?= L_FAVORITES; ?>
<?= lang('Favorites'); ?>
</a>
<?php if($uid['trust_level'] == 5) { ?>
<a href="/admin" target="_black">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#ad"></use>
</svg>
<?= L_ADMIN; ?>
<?= lang('Admin'); ?>
</a>
<?php } ?>
<hr>
<a href="/logout" class="logout" target="_self" title="<?= L_LOGOUT; ?>">
<a href="/logout" class="logout" target="_self" title="<?= lang('Sign out'); ?>">
<svg class="md-icon">
<use xlink:href="/assets/svg/icons.svg#arrow-bar-to-right"></use>
</svg>
<?= L_LOGOUT; ?>
<?= lang('Sign out'); ?>
</a>
</span>
</li>