Просмотр исходного кода

System update (multi language remix)

markseu 8 лет назад
Родитель
Сommit
d99c5db688

+ 2 - 1
system/config/config.ini

@@ -35,7 +35,8 @@ ContentExtension: .txt
 ConfigExtension: .ini
 DownloadExtension: .download
 InstallationExtension: .installation
-TextFile: language-(.*).txt
+TextFile: text.ini
+LanguageFile: language-(.*).txt
 ErrorFile: page-error-(.*).txt
 RobotsFile: robots.txt
 FaviconFile: favicon.ico

+ 15 - 7
system/plugins/core.php

@@ -12,7 +12,7 @@ class YellowCore
 	var $plugins;			//plugins
 	var $themes;			//themes
 	var $config;			//configuration
-	var $text;				//text strings
+	var $text;				//text
 	var $lookup;			//location and file lookup
 	var $toolbox;			//toolbox with helpers
 
@@ -62,7 +62,8 @@ class YellowCore
 		$this->config->setDefault("downloadExtension", ".download");
 		$this->config->setDefault("installationExtension", ".installation");
 		$this->config->setDefault("configFile", "config.ini");
-		$this->config->setDefault("textFile", "language-(.*).txt");
+		$this->config->setDefault("textFile", "text.ini");
+		$this->config->setDefault("languageFile", "language-(.*).txt");
 		$this->config->setDefault("errorFile", "page-error-(.*).txt");
 		$this->config->setDefault("robotsFile", "robots.txt");
 		$this->config->setDefault("faviconFile", "favicon.ico");
@@ -94,17 +95,19 @@ class YellowCore
 		}
 		$this->toolbox->timerStart($time);
 		$this->config->load($this->config->get("configDir").$this->config->get("configFile"));
-		$this->text->load($this->config->get("pluginDir").$this->config->get("textFile"));
 		$this->lookup->load();
 		$this->themes->load();
 		$this->plugins->load();
+		$this->text->load($this->config->get("pluginDir").$this->config->get("languageFile"), "");
+		$this->text->load($this->config->get("configDir").$this->config->get("textFile"), $this->config->get("language"));
 		$this->toolbox->timerStop($time);
 		$this->startup();
 		if(defined("DEBUG") && DEBUG>=2)
 		{
 			$plugins = count($this->plugins->plugins);
 			$themes = count($this->themes->themes);
-			echo "YellowCore::load plugins:$plugins themes:$themes time:$time ms<br/>\n";
+			$languages = count($this->text->text);
+			echo "YellowCore::load plugins:$plugins themes:$themes languages:$languages time:$time ms<br/>\n";
 		}
 	}
 	
@@ -1952,7 +1955,7 @@ class YellowText
 {
 	var $yellow;		//access to API
 	var $modified;		//text modification date
-	var $text;			//text strings
+	var $text;			//text
 	var $language;		//current language
 	
 	function __construct($yellow)
@@ -1963,14 +1966,14 @@ class YellowText
 	}
 	
 	// Load text strings from file
-	function load($fileName)
+	function load($fileName, $languageDefault)
 	{
 		$path = dirname($fileName);
 		$regex = "/^".basename($fileName)."$/";
 		foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false) as $entry)
 		{
 			if(defined("DEBUG") && DEBUG>=2) echo "YellowText::load file:$entry<br/>\n";
-			$language = "";
+			$language = $languageDefault;
 			$this->modified = max($this->modified, filemtime($entry));
 			$fileData = $this->yellow->toolbox->readFile($entry);
 			foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
@@ -2051,10 +2054,15 @@ class YellowText
 		$dateWeekdays = preg_split("/\s*,\s*/", $this->get("dateWeekdays"));
 		$month = $dateMonths[date('n', $timestamp) - 1];
 		$weekday = $dateWeekdays[date('N', $timestamp) - 1];
+		$timeZone = $this->yellow->config->get("timezone");
+		$timeZoneHelper = new DateTime(null, new DateTimeZone($timeZone));
+		$timeZoneOffset = $timeZoneHelper->getOffset();
+		$timeZoneAbbreviation = "GMT".($timeZoneOffset<0 ? "-" : "+").abs(intval($timeZoneOffset/3600));
 		$format = preg_replace("/(?<!\\\)F/", addcslashes($month, 'A..Za..z'), $format);
 		$format = preg_replace("/(?<!\\\)M/", addcslashes(substru($month, 0, 3), 'A..Za..z'), $format);
 		$format = preg_replace("/(?<!\\\)D/", addcslashes(substru($weekday, 0, 3), 'A..Za..z'), $format);
 		$format = preg_replace("/(?<!\\\)l/", addcslashes($weekday, 'A..Za..z'), $format);
+		$format = preg_replace("/(?<!\\\)T/", addcslashes($timeZoneAbbreviation, 'A..Za..z'), $format);
 		return date($format, $timestamp);
 	}
 	

+ 5 - 3
system/plugins/language-de.txt

@@ -24,7 +24,6 @@ DateWeekstart: Montag
 DateFormatShort: F Y
 DateFormatMedium: d.m.Y
 DateFormatLong: d.m.Y H:i
-DateFormatTime: H:i
 EditInstallationTitle: Hallo
 EditInstallationFeature: Was willst du machen?
 EditInstallationHomePage: Deine Webseite funktioniert!\n\nDu kannst [edit - diese Seite bearbeiten] oder einen Texteditor benutzen.
@@ -116,10 +115,13 @@ SearchResultsNone: Bitte einen Suchbegriff eingeben.
 SearchResultsEmpty: Keine Treffer für diese Suchanfrage.
 SearchSpecialChanges: Letzte Änderungen
 SearchButton: Suchen
+TimeFormatShort: H:i
+TimeFormatMedium: H:i:s
+TimeFormatLong: H:i:s T
 WikiFilter: Wiki:
 WikiTag: Tags:
 WikiSpecialPages: Alle Seiten
 WikiSpecialChanges: Letzte Änderungen
 YellowUrl: https://datenstrom.se/de/yellow/
-YellowUserHelpUrl: https://developers.datenstrom.se/help/help-de
-YellowMarkdownHelpUrl: https://developers.datenstrom.se/help/markdown-cheat-sheet-de
+YellowUserHelpUrl: https://developers.datenstrom.se/de/help/
+YellowMarkdownHelpUrl: https://developers.datenstrom.se/de/help/markdown-cheat-sheet

+ 3 - 1
system/plugins/language-en.txt

@@ -24,7 +24,6 @@ DateWeekstart: Monday
 DateFormatShort: F Y
 DateFormatMedium: Y-m-d
 DateFormatLong: Y-m-d H:i
-DateFormatTime: H:i
 EditInstallationTitle: Hello
 EditInstallationFeature: What do you want to make?
 EditInstallationHomePage: Your website works!\n\nYou can [edit this page] or use your text editor.
@@ -116,6 +115,9 @@ SearchResultsNone: Enter a search term.
 SearchResultsEmpty: No results found.
 SearchSpecialChanges: Recent changes
 SearchButton: Search
+TimeFormatShort: H:i
+TimeFormatMedium: H:i:s
+TimeFormatLong: H:i:s T
 WikiFilter: Wiki:
 WikiTag: Tags:
 WikiSpecialPages: All pages

+ 5 - 3
system/plugins/language-fr.txt

@@ -24,7 +24,6 @@ DateWeekstart: lundi
 DateFormatShort: F Y
 DateFormatMedium: d/m/Y
 DateFormatLong: d/m/Y H:i
-DateFormatTime: H:i
 EditInstallationTitle: Bonjour
 EditInstallationFeature: Que voulez-vous faire?
 EditInstallationHomePage: Votre site web fonctionne!\n\nVous pouvez [edit - modifier cette page] ou utiliser un éditeur de texte.
@@ -116,10 +115,13 @@ SearchResultsNone: Entrez un mot dans le champ de recherche.
 SearchResultsEmpty: Pas de résultats.
 SearchSpecialChanges: Changements récents
 SearchButton: Rechercher
+TimeFormatShort: H:i
+TimeFormatMedium: H:i:s
+TimeFormatLong: H:i:s T
 WikiFilter: Wiki:
 WikiTag: Tags:
 WikiSpecialPages: Toutes les pages
 WikiSpecialChanges: Changements récents
 YellowUrl: https://datenstrom.se/fr/yellow/
-YellowUserHelpUrl: https://developers.datenstrom.se/help/help-fr
-YellowMarkdownHelpUrl: https://developers.datenstrom.se/help/markdown-cheat-sheet-fr
+YellowUserHelpUrl: https://developers.datenstrom.se/fr/help/
+YellowMarkdownHelpUrl: https://developers.datenstrom.se/fr/help/markdown-cheat-sheet