Commit cefb8d54 authored by Tino Goratsch's avatar Tino Goratsch

added the library `fisharebest/localization` which handles to retrieval of the...

added the library `fisharebest/localization` which handles to retrieval of the output of the localzized name of a language pack and the script direction
parent 5986e073
......@@ -9,6 +9,7 @@ namespace ACP3\Core\I18n;
use ACP3\Core\Cache;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Modules\Vendor;
use Fisharebest\Localization\Locale;
/**
* Class Cache
......@@ -16,6 +17,8 @@ use ACP3\Core\Modules\Vendor;
*/
class DictionaryCache
{
use ExtractFromPathTrait;
/**
* @var Cache
*/
......@@ -32,9 +35,9 @@ class DictionaryCache
/**
* DictionaryCache constructor.
*
* @param \ACP3\Core\Cache $cache
* @param \ACP3\Core\Cache $cache
* @param \ACP3\Core\Environment\ApplicationPath $appPath
* @param \ACP3\Core\Modules\Vendor $vendors
* @param \ACP3\Core\Modules\Vendor $vendors
*/
public function __construct(
Cache $cache,
......@@ -78,14 +81,15 @@ class DictionaryCache
if ($languageFiles !== false) {
foreach ($languageFiles as $file) {
$xml = simplexml_load_file($file);
if (isset($data['info']['direction']) === false) {
$data['info']['direction'] = (string)$xml->info->direction;
$locale = Locale::create($this->getLanguagePackIsoCode($file));
$data['info']['direction'] = $locale->script()->direction();
}
$module = $this->getModuleFromPath($file);
// Iterate over all language keys
$xml = simplexml_load_file($file);
foreach ($xml->keys->item as $item) {
$data['keys'][strtolower($module . (string)$item['key'])] = trim((string)$item);
}
......@@ -96,18 +100,6 @@ class DictionaryCache
return $this->cache->save($language, $data);
}
/**
* @param string $path
*
* @return string
*/
protected function getModuleFromPath($path)
{
$pathArray = explode('/', $path);
return $pathArray[count($pathArray) - 4];
}
/**
* Gets the cache for all registered languages
*
......@@ -155,29 +147,19 @@ class DictionaryCache
*/
protected function registerLanguagePack($file)
{
$xml = simplexml_load_file($file);
$languageIso = $this->getLanguagePackIsoCode($file);
if (!empty($xml)) {
$languageIso = $this->getLanguagePackIsoCode($file);
try {
$locale = Locale::create($languageIso);
return [
$languageIso => [
'iso' => $languageIso,
'name' => (string)$xml->info->name
'name' => $locale->endonym()
]
];
} catch (\DomainException $e) {
return [];
}
return [];
}
/**
* @param string $file
*
* @return string
*/
protected function getLanguagePackIsoCode($file)
{
return substr($file, strrpos($file, '/') + 1, -4);
}
}
<?php
/**
* Copyright (c) 2017 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\I18n;
trait ExtractFromPathTrait
{
/**
* @param string $filePath
*
* @return string
*/
protected function getLanguagePackIsoCode($filePath)
{
return substr($filePath, strrpos($filePath, '/') + 1, -4);
}
/**
* @param string $filePath
*
* @return string
*/
protected function getModuleFromPath($filePath)
{
$pathArray = explode('/', $filePath);
return $pathArray[count($pathArray) - 4];
}
}
......@@ -18,6 +18,8 @@
"acp3/composer-installer": "*",
"doctrine/dbal": "^2.5",
"doctrine/cache": "^1.6",
"fisharebest/localization": "^1.10",
"giggsey/locale": "^1.2",
"inlinestyle/inlinestyle": "^1.2",
"monolog/monolog": "^1.21",
"mrclay/minify": "^2.3",
......@@ -31,8 +33,7 @@
"symfony/http-kernel": "^3.1",
"symfony/yaml": "^3.1",
"symfony/event-dispatcher": "^3.1",
"friendsofsymfony/http-cache": "~1.0",
"giggsey/locale": "^1.2"
"friendsofsymfony/http-cache": "~1.0"
},
"autoload": {
"psr-4": {
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_to_modules">Sie haben Zugriff auf folgende Module:</item>
<item key="acp">Administration</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_to_modules">You have access to the following modules:</item>
<item key="acp">Administration</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neuen Artikel erstellen</item>
<item key="admin_index_delete">Artikel löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new article</item>
<item key="admin_index_delete">Delete article</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Einstellungen</item>
<item key="captcha">Captcha</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Settings</item>
<item key="captcha">Captcha</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neue Kategorie erstellen</item>
<item key="admin_index_delete">Kategorien löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new category</item>
<item key="admin_index_delete">Delete categories</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_delete">Kommentare löschen</item>
<item key="admin_index_settings">Einstellungen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_delete">Delete comments</item>
<item key="admin_index_settings">Settings</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="address">Anschrift</item>
<item key="address_to_short">Die Anschrift darf nicht leer sein.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="address">Address</item>
<item key="address_to_short">The address should not be empty.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Emoticon hinzufügen</item>
<item key="admin_index_delete">Emoticon löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new emoticon</item>
<item key="admin_index_delete">Delete emoticons</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_denied">Es ist ihnen nicht gestattet auf diese Seite zuzugreifen, da Sie die dafür benötigtenZugriffsrechte nicht besitzen.</item>
<item key="errors">Fehlermeldungen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_denied">You don't have the needed rights to view this page.</item>
<item key="errors">Error messages</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Einstellungen</item>
<item key="feed_image">Feed Bild</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_settings">Settings</item>
<item key="feed_image">Feed image</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="filemanager">Dateimanager</item>
<item key="mod_description">Dieses Modul ermöglicht die Nutzung eines Datei Managers.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="filemanager">File Manager</item>
<item key="mod_description">This module enables the usage of a file manager.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neuen Download erstellen</item>
<item key="admin_index_delete">Downloads löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new download</item>
<item key="admin_index_delete">Delete downloads</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neue Fotogalerie erstellen</item>
<item key="admin_index_delete">Fotogalerien löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new gallery</item>
<item key="admin_index_delete">Delete galleries</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="activate_entry">Eintrag freischalten</item>
<item key="admin_index_delete">Gästebucheinträge löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="activate_entry">Approve entry</item>
<item key="admin_index_delete">Delete guestbook entries</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neue Navigationsleiste erstellen</item>
<item key="admin_index_delete">Navigationsleiste löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new menu bar</item>
<item key="admin_index_delete">Delete menu bar</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="activate_readmore">&quot;Weiterlesen...&quot; aktivieren</item>
<item key="admin_index_create">Neue News erstellen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new news</item>
<item key="admin_index_delete">Delete news</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="account_activation_credentials_wrong">Die übermittelten Daten konnten keinem Newsletter-Konto zugeordnert werden.</item>
<item key="account_exists">Für die angegebene E-Mail-Adresse existiert bereits ein Newsletter-Konto.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="account_activation_credentials_wrong">Can not find any associated newsletter account.</item>
<item key="account_exists">There is already an newsletter account with the same E-Mail address registered.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neue Rolle erstellen</item>
<item key="admin_index_delete">Rolle löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new role</item>
<item key="admin_index_delete">Delete roles</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neue Umfrage erstellen</item>
<item key="admin_index_delete">Umfragen löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create new poll</item>
<item key="admin_index_delete">Delete polls</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="advanced_search">Erweiterte Suche</item>
<item key="asc">Aufsteigend</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="advanced_search">Advanced search</item>
<item key="asc">Ascending</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Neuen URL-Rewrite erstellen</item>
<item key="admin_index_delete">URL-Rewrites löschen</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="admin_index_create">Create a new URL-Rewrite</item>
<item key="admin_index_delete">Delete URL-Rewrites</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_to_following_modules">Sie haben Zugriff auf folgende %d Module.</item>
<item key="acp3_not_up_to_date">Es ist eine neue Version des ACP3 verfügbar. Sie kann %link_start%hier%link_end%
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="access_to_following_modules">You have access to the following %d modules.</item>
<item key="acp3_not_up_to_date">A newer version of ACP3 is available. Click %link_start%here%link_end% to
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="account_locked">Ihr Benutzerkonto wurde gesperrt. Um es wieder zu aktivieren, verwenden Sie bitte die &quot;Passwort vergessen&quot; Funktion, welche Ihnen dann ein neues Passwort zusenden wird.</item>
<item key="address">Adresse</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="account_locked">Your user account has been locked. To reactivate it, please use the &quot;forgot password&quot; function, to receive a new password.</item>
<item key="address">Address</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygckeditor">CKEditor (WYSIWYG-Editor)</item>
<item key="mod_description">Dieses Modul ermöglicht die Nutzung des CKEditor WYSIWYG-Editors.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygckeditor">CKEditor (WYSIWYG editor)</item>
<item key="mod_description">This module enables the usage of the CKEditor WYSIWYG editor.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>Deutsch (Deutschland)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygtinymce">TinyMCE (WYSIWYG-Editor)</item>
<item key="mod_description">Dieses Modul ermöglicht die Nutzung des TinyMCE WYSIWYG-Editors.</item>
......
<?xml version="1.0" encoding="UTF-8"?>
<language>
<info>
<name>English (United States)</name>
<direction>ltr</direction>
</info>
<keys>
<item key="wysiwygtinymce">TinyMCE (WYSIWYG editor)</item>
<item key="mod_description">This module enables the usage of the TinyMCE WYSIWYG editor.</item>
......
......@@ -6,11 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] - 2017-xx-xx
### Added
- Added the library `fisharebest/localization` which handles to retrieval of the output of the localzized name of a language pack and the script direction
- Added the new trait `AvailableDesignsTrait` which makes it possible to share the design retrieval logic between the installer and the rest of the system
- Made it possible to use the AJAX-form hash change logic for redirects, too
### Changed
- Added some guards to various modules to make them more robust
- Replaced the library `umpirsky/country-list` with `giggsey/locale` because of its significantly reduced storage footprint
## [4.9.2] - 2017-03-26
### Fixed
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "dbc39506810c6707cbdd9b9150fd16cc",
"content-hash": "b6cd27888a47f49e829cfc8d1753bd62",
"packages": [
{