1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

Using I18n Component

This commit is contained in:
Awilum
2018-04-27 23:54:47 +03:00
parent a6c0927751
commit 1944101496
2 changed files with 54 additions and 1 deletions

View File

@@ -27,7 +27,8 @@
"flextype-components/token" : "1.*",
"flextype-components/filesystem" : "1.*",
"flextype-components/event" : "1.*",
"flextype-components/view" : "1.*"
"flextype-components/view" : "1.*",
"flextype-components/i18n" : "dev-master"
},
"autoload": {
"classmap": [

View File

@@ -24,6 +24,46 @@ class Plugins
*/
protected static $instance = null;
/**
* Locales array
*
* @var array
*/
public static $locales = [
'ar' => 'العربية',
'bg' => 'Български',
'ca' => 'Català',
'cs' => 'Česky',
'da' => 'Dansk',
'de' => 'Deutsch',
'el' => 'Ελληνικά',
'en' => 'English',
'es' => 'Español',
'fa' => 'Farsi',
'fi' => 'Suomi',
'fr' => 'Français',
'gl' => 'Galego',
'ka-ge' => 'Georgian',
'hu' => 'Magyar',
'it' => 'Italiano',
'id' => 'Bahasa Indonesia',
'ja' => '日本語',
'lt' => 'Lietuvių',
'nl' => 'Nederlands',
'no' => 'Norsk',
'pl' => 'Polski',
'pt' => 'Português',
'pt-br' => 'Português do Brasil',
'ru' => 'Русский',
'sk' => 'Slovenčina',
'sl' => 'Slovenščina',
'sv' => 'Svenska',
'sr' => 'Srpski',
'tr' => 'Türkçe',
'uk' => 'Українська',
'zh-cn' => '简体中文',
];
/**
* Protected constructor since this is a static class.
*
@@ -88,6 +128,18 @@ class Plugins
}
}
// Create dictionary
if (is_array($plugins_list) && count($plugins_list) > 0) {
foreach (static::$locales as $locale => $locale_title) {
foreach ($plugins_list as $plugin) {
$language_file = PLUGINS_PATH . '/' . $plugin . '/languages/' . $locale . '.yml';
if (Filesystem::fileExists($language_file)) {
I18n::add($plugin, $locale, Yaml::parseFile($language_file));
}
}
}
}
// Include enabled plugins
if (is_array(Config::get('plugins')) && count(Config::get('plugins')) > 0) {
foreach (Config::get('plugins') as $plugin_name => $plugin) {