mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Localization: Code refactoring (#107)
So, it's no longer looks like shit. The commiter can just add their language to list.yml and make a strings file, and he is done: His name will be automatically added to About page and the language itself will appear in the list
This commit is contained in:
parent
0fcdcd4b46
commit
d2e7602eb5
6 changed files with 87 additions and 47 deletions
|
@ -54,17 +54,20 @@ final class AboutPresenter extends OpenVKPresenter
|
|||
function renderVersion(): void
|
||||
{
|
||||
$this->template->themes = Themepacks::i()->getAllThemes();
|
||||
$this->template->languages = getLanguages();
|
||||
}
|
||||
|
||||
function renderLanguage(): void
|
||||
{
|
||||
$this->template->languages = getLanguages();
|
||||
|
||||
if(!is_null($_GET['lg'])){
|
||||
Session::i()->set("lang", $_GET['lg']);
|
||||
setLanguage($_GET['lg']);
|
||||
}
|
||||
}
|
||||
|
||||
function renderSandbox(): void
|
||||
{
|
||||
$this->template->manager = (new Managers)->get(4);
|
||||
$this->template->languages = getLanguages();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,8 @@
|
|||
|
||||
{block content}
|
||||
<div class="navigation">
|
||||
<a href="language?lg=ru" class="link"><img src="/assets/packages/static/openvk/img/flags/ru.gif"> Русский</a>
|
||||
<a href="language?lg=en" class="link"><img src="/assets/packages/static/openvk/img/flags/us.gif"> English</a>
|
||||
<a href="language?lg=ua" class="link"><img src="/assets/packages/static/openvk/img/flags/ua.gif"> Україньска</a>
|
||||
<a href="language?lg=by" class="link"><img src="/assets/packages/static/openvk/img/flags/by.gif"> Беларуская (Наркамоўка)</a>
|
||||
<a href="language?lg=by_lat" class="link"><img src="/assets/packages/static/openvk/img/flags/by.gif"> Biełaruskaja (Łacinka)</a>
|
||||
<a href="language?lg=pl" class="link"><img src="/assets/packages/static/openvk/img/flags/pl.gif"> Polski</a>
|
||||
<a href="language?lg=de" class="link"><img src="/assets/packages/static/openvk/img/flags/de.gif"> Deutsch</a>
|
||||
<a href="language?lg=am" class="link"><img src="/assets/packages/static/openvk/img/flags/am.gif"> Հայերեն</a>
|
||||
<a href="language?lg=sr_cyr" class="link"><img src="/assets/packages/static/openvk/img/flags/rs.gif"> Спрски (Ћирилица)</a>
|
||||
<a href="language?lg=sr_lat" class="link"><img src="/assets/packages/static/openvk/img/flags/rs.gif"> Sprski (Latinica)</a>
|
||||
<a href="language?lg=tr" class="link"><img src="/assets/packages/static/openvk/img/flags/tr.gif"> Türkçe</a>
|
||||
{foreach $languages as $language}
|
||||
<a href="language?lg={$language['code']}" class="link"><img src="/assets/packages/static/openvk/img/flags/{$language['flag']}.gif"> {$language['native_name']}</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/block}
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
{/block}
|
||||
|
||||
{block content}
|
||||
{$manager->getUser()->getFullName()}
|
||||
{php var_dump($languages)}
|
||||
{/block}
|
||||
|
|
|
@ -410,48 +410,26 @@
|
|||
<table>
|
||||
<tbody>
|
||||
<tr class="h">
|
||||
<th colspan="2">Languagepacks</th>
|
||||
<th colspan="3">Languagepacks</th>
|
||||
</tr>
|
||||
<tr class="h">
|
||||
<td>
|
||||
Language
|
||||
</td>
|
||||
<td>
|
||||
Native name
|
||||
</td>
|
||||
<td>
|
||||
Author
|
||||
</td>
|
||||
</tr>
|
||||
{foreach $languages as $language}
|
||||
<tr>
|
||||
<td class="e">Russian</td>
|
||||
<td class="v">Vladimir Barinov (veselcraft)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">English</td>
|
||||
<td class="v">Vladimir Barinov (veselcraft)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">Belarussian</td>
|
||||
<td class="v">Daniil Myslivets (myslivets) and MoccoCoffee</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">Serbian</td>
|
||||
<td class="v">Ivan Denisov (Dma Games)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">Turkish</td>
|
||||
<td class="v">Bedirhan Kurt (WindOWZ)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">Armenian</td>
|
||||
<td class="v">apeeh</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">German</td>
|
||||
<td class="v">SamyoFox</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">Ukrainian</td>
|
||||
<td class="v">Andrej Lenťaj</td>
|
||||
<td class="e">{$language['name']}</td>
|
||||
<td class="v">{$language['native_name']}</td>
|
||||
<td class="v">{$language['author']}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -96,6 +96,16 @@ function tr(string $stringId, ...$variables): string
|
|||
return $output;
|
||||
}
|
||||
|
||||
function setLanguage($lg): void
|
||||
{
|
||||
Session::i()->set("lang", $lg);
|
||||
}
|
||||
|
||||
function getLanguages(): array
|
||||
{
|
||||
return yaml_parse_file(OPENVK_ROOT . "/locales/list.yml")['list'];
|
||||
}
|
||||
|
||||
function eventdb(): ?DatabaseConnection
|
||||
{
|
||||
$conf = OPENVK_ROOT_CONF["openvk"]["credentials"]["eventDB"];
|
||||
|
|
57
locales/list.yml
Normal file
57
locales/list.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
list:
|
||||
- code: "ru"
|
||||
flag: "ru"
|
||||
name: "Russian"
|
||||
native_name: "Русский"
|
||||
author: "OpenVK Team"
|
||||
- code: "en"
|
||||
flag: "us"
|
||||
name: "English"
|
||||
native_name: "English"
|
||||
author: "OpenVK Team"
|
||||
- code: "ua"
|
||||
flag: "ua"
|
||||
name: "Ukrainian"
|
||||
native_name: "Україньска"
|
||||
author: "Andrej Lenťaj and Maxim Hrabovi (dechioyo)"
|
||||
- code: "by"
|
||||
flag: "by"
|
||||
name: "Belarussian"
|
||||
native_name: "Беларуская (Наркамоўка)"
|
||||
author: "Daniil Myslivets (myslivets) and MoccoCoffee"
|
||||
- code: "by_lat"
|
||||
flag: "by"
|
||||
name: "Belarussian (Latin)"
|
||||
native_name: "Biełaruskaja (Łacinka)"
|
||||
author: "MoccoCoffee"
|
||||
- code: "pl"
|
||||
flag: "pl"
|
||||
name: "Polish"
|
||||
native_name: "Polski"
|
||||
author: "Kirill (mbsoft)"
|
||||
- code: "de"
|
||||
flag: "de"
|
||||
name: "German"
|
||||
native_name: "Deutsch"
|
||||
author: "SamyoFox"
|
||||
- code: "am"
|
||||
flag: "am"
|
||||
name: "Armenian"
|
||||
native_name: "Հայերեն"
|
||||
author: "LifesMinder (apeeh)"
|
||||
- code: "sr_cyr"
|
||||
flag: "rs"
|
||||
name: "Serbian (cyrillic)"
|
||||
native_name: "Спрски (Ћирилица)"
|
||||
author: "Ivan Denisov (Dma Games)"
|
||||
- code: "sr_lat"
|
||||
flag: "rs"
|
||||
name: "Serbian (latin)"
|
||||
native_name: "Sprski (Latinica)"
|
||||
author: "Ivan Denisov (Dma Games)"
|
||||
- code: "tr"
|
||||
flag: "tr"
|
||||
name: "Turkish"
|
||||
native_name: "Türkçe"
|
||||
author: "Bedirhan Kurt (WindOWZ)"
|
||||
|
Loading…
Reference in a new issue