mirror of
https://github.com/typemill/typemill.git
synced 2025-10-18 16:16:08 +02:00
translations integrated, hero images, image classes
This commit is contained in:
@@ -38,15 +38,21 @@ class Settings
|
||||
}
|
||||
}
|
||||
|
||||
# i18n
|
||||
# load the strings of the set language
|
||||
$language = $settings['language'];
|
||||
$theme = $settings['theme'];
|
||||
$plugins = [];
|
||||
if(isset($settings['plugins'])){
|
||||
$plugins = $settings['plugins'];
|
||||
}
|
||||
$settings['labels'] = self::getLanguageLabels($language, $theme, $plugins);
|
||||
# let us load translations only for admin area to improve performance for frontend
|
||||
$uri = $_SERVER[REQUEST_URI];
|
||||
if(isset($uri) && (strpos($uri,'/tm/') !== false OR strpos($uri,'/setup') !== false))
|
||||
{
|
||||
# i18n
|
||||
# load the strings of the set language
|
||||
$language = $settings['language'];
|
||||
$theme = $settings['theme'];
|
||||
$plugins = [];
|
||||
if(isset($settings['plugins']))
|
||||
{
|
||||
$plugins = $settings['plugins'];
|
||||
}
|
||||
$settings['labels'] = self::getLanguageLabels($language, $theme, $plugins);
|
||||
}
|
||||
|
||||
# We know the used theme now so create the theme path
|
||||
$settings['themePath'] = $settings['rootPath'] . $settings['themeFolder'] . DIRECTORY_SEPARATOR . $settings['theme'];
|
||||
@@ -72,6 +78,7 @@ class Settings
|
||||
'author' => 'Unknown',
|
||||
'copyright' => 'Copyright',
|
||||
'language' => 'en',
|
||||
'langattr' => 'en',
|
||||
'startpage' => true,
|
||||
'rootPath' => $rootPath,
|
||||
'themeFolder' => 'themes',
|
||||
@@ -85,7 +92,7 @@ class Settings
|
||||
'contentFolder' => 'content',
|
||||
'cache' => true,
|
||||
'cachePath' => $rootPath . 'cache',
|
||||
'version' => '1.3.5',
|
||||
'version' => '1.3.6',
|
||||
'setup' => true,
|
||||
'welcome' => true,
|
||||
'images' => ['live' => ['width' => 820], 'thumbs' => ['width' => 250, 'height' => 150]],
|
||||
@@ -113,37 +120,61 @@ class Settings
|
||||
|
||||
# loads the system strings of the set language
|
||||
$yaml = new Models\WriteYaml();
|
||||
$system_labels = $yaml->getYaml('system/author/languages', $language.'.yaml');
|
||||
$system_labels = $yaml->getYaml('system' . DIRECTORY_SEPARATOR . 'author' . DIRECTORY_SEPARATOR . 'languages', $language . '.yaml');
|
||||
|
||||
# loads the theme strings of the set language
|
||||
$theme_labels = [];
|
||||
$theme_language_folder = 'themes/'.$theme.'/languages';
|
||||
if (file_exists($theme_language_folder)) {
|
||||
$theme_labels = $yaml->getYaml($theme_language_folder, $language.'.yaml');
|
||||
}
|
||||
# loads the theme strings of the set language
|
||||
$theme_labels = [];
|
||||
$theme_language_folder = 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR;
|
||||
$theme_language_file = $language . '.yaml';
|
||||
if (file_exists($theme_language_folder . $theme_language_file))
|
||||
{
|
||||
$theme_labels = $yaml->getYaml($theme_language_folder, $theme_language_file);
|
||||
}
|
||||
|
||||
# loads the plugins strings of the set language
|
||||
$plugins_labels = [];
|
||||
if(!empty($plugins)){
|
||||
$plugin_labels = [];
|
||||
foreach($plugins as $name => $value){
|
||||
$plugin_language_folder = 'plugins/'.$name.'/languages';
|
||||
if (file_exists($theme_language_folder)) {
|
||||
$plugin_labels[$name] = $yaml->getYaml($plugin_language_folder, $language.'.yaml');
|
||||
}
|
||||
}
|
||||
$plugins_labels = [];
|
||||
foreach($plugin_labels as $key => $value){
|
||||
$plugins_labels = array_merge($plugins_labels, $value);
|
||||
}
|
||||
}
|
||||
# loads the plugins strings of the set language
|
||||
$plugins_labels = [];
|
||||
if(!empty($plugins))
|
||||
{
|
||||
$plugin_labels = [];
|
||||
foreach($plugins as $name => $value)
|
||||
{
|
||||
$plugin_language_folder = 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR;
|
||||
$plugin_language_file = $language . '.yaml';
|
||||
|
||||
# Combines arrays of system languages, themes and plugins
|
||||
$labels = array_merge($system_labels, $theme_labels, $plugins_labels);
|
||||
if (file_exists($plugin_language_folder . $plugin_language_file))
|
||||
{
|
||||
$plugin_labels[$name] = $yaml->getYaml($plugin_language_folder, $plugin_language_file);
|
||||
}
|
||||
}
|
||||
foreach($plugin_labels as $key => $value)
|
||||
{
|
||||
$plugins_labels = array_merge($plugins_labels, $value);
|
||||
}
|
||||
}
|
||||
|
||||
# Combines arrays of system languages, themes and plugins
|
||||
$labels = array_merge($system_labels, $theme_labels, $plugins_labels);
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
public function whichLanguage()
|
||||
{
|
||||
# Check which languages are available
|
||||
$langs = [];
|
||||
$path = __DIR__ . '/author/languages/*.yaml';
|
||||
|
||||
foreach (glob($path) as $filename)
|
||||
{
|
||||
$langs[] = basename($filename,'.yaml');
|
||||
}
|
||||
|
||||
# Detect browser language
|
||||
$accept_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
$lang = in_array($accept_lang, $langs) ? $accept_lang : 'en';
|
||||
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public static function getObjectSettings($objectType, $objectName)
|
||||
{
|
||||
@@ -155,28 +186,12 @@ class Settings
|
||||
|
||||
return $objectSettings;
|
||||
}
|
||||
|
||||
public function whichLanguage()
|
||||
{
|
||||
# Check which languages are available
|
||||
$langs = [];
|
||||
$path = __DIR__ . '/author/languages/*.yaml';
|
||||
foreach (glob($path) as $filename) {
|
||||
$langs[] = basename($filename,'.yaml');
|
||||
}
|
||||
|
||||
# Detect browser language
|
||||
$accept_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
$lang = in_array($accept_lang, $langs) ? $accept_lang : 'en';
|
||||
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public static function createSettings()
|
||||
{
|
||||
$yaml = new Models\WriteYaml();
|
||||
|
||||
$language = self::whichLanguage();
|
||||
$language = self::whichLanguage();
|
||||
|
||||
# create initial settings file with only setup false
|
||||
if($yaml->updateYaml('settings', 'settings.yaml', array('setup' => false, 'language' => $language)))
|
||||
@@ -198,6 +213,7 @@ class Settings
|
||||
'title' => true,
|
||||
'copyright' => true,
|
||||
'language' => true,
|
||||
'langattr' => true,
|
||||
'startpage' => true,
|
||||
'author' => true,
|
||||
'year' => true,
|
||||
|
Reference in New Issue
Block a user