diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index f0952f2dcd07daa62ff4453df140a0317d7c3c33..d7716b5af7add2b5b337355f2d25120b6f3fa8fd 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -434,49 +434,83 @@ class SimpleSAML_XHTML_Template {
 
 
 	/**
-	 * Read a dictionary file.
+	 * Read a dictionary file in json format.
 	 *
-	 * @param $filename  The absolute path to the dictionary file.
-	 * @return The translation array which was found in the dictionary file.
+	 * @param string $filename  The absolute path to the dictionary file, minus the .definition.json ending.
+	 * @return array  The translation array from the file.
 	 */
-	private function readDictionaryFile($filename) {
-		assert('is_string($filename)');
-		
+	private function readDictionaryJSON($filename) {
 		$definitionFile = $filename . '.definition.json';
-		$translationFile = $filename . '.translation.json';
+		assert('file_exists($definitionFile)');
 
-		SimpleSAML_Logger::debug('Template: Reading [' . $filename . ']');
-
-		if (!file_exists($definitionFile)) {
-			SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $definitionFile . ']');
-					
-			return array();
-		}
-		
 		$fileContent = file_get_contents($definitionFile);
-		$fileArray = json_decode($fileContent, TRUE);
-		
-		if (empty($fileArray)) {
+		$lang = json_decode($fileContent, TRUE);
+
+		if (empty($lang)) {
 			SimpleSAML_Logger::error('Invalid dictionary definition file [' . $definitionFile . ']');
 			return array();
 		}
-		
-		$lang = json_decode($fileContent, TRUE);
 
-		$moreTrans = NULL;
+		$translationFile = $filename . '.translation.json';
 		if (file_exists($translationFile)) {
 			$fileContent = file_get_contents($translationFile);
 			$moreTrans = json_decode($fileContent, TRUE);
+			if (!empty($moreTrans)) {
+				$lang = self::lang_merge($lang, $moreTrans);
+			}
+		}
+
+		return $lang;
+	}
+
+
+	/**
+	 * Read a dictionary file in PHP format.
+	 *
+	 * @param string $filename  The absolute path to the dictionary file.
+	 * @return array  The translation array from the file.
+	 */
+	private function readDictionaryPHP($filename) {
+		$phpFile = $filename . '.php';
+		assert('file_exists($phpFile)');
 
+		$lang = NULL;
+		include($phpFile);
+		if (isset($lang)) {
+			return $lang;
 		}
-		if (!empty($moreTrans))
-			$lang = self::lang_merge($lang, $moreTrans);
 
-		// echo '<pre>'; print_r($lang); exit;
+		return array();
+	}
 
-		return $lang;
+
+	/**
+	 * Read a dictionary file.
+	 *
+	 * @param $filename  The absolute path to the dictionary file.
+	 * @return The translation array which was found in the dictionary file.
+	 */
+	private function readDictionaryFile($filename) {
+		assert('is_string($filename)');
+
+		SimpleSAML_Logger::debug('Template: Reading [' . $filename . ']');
+
+		$jsonFile = $filename . '.definition.json';
+		if (file_exists($jsonFile)) {
+			return $this->readDictionaryJSON($filename);
+		}
+
+
+		$phpFile = $filename . '.php';
+		if (file_exists($phpFile)) {
+			return $this->readDictionaryPHP($filename);
+		}
+
+		SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
+		return array();
 	}
-	
+
+
 	// Merge two translation arrays.
 	public static function lang_merge($def, $lang) {
 		foreach($def AS $key => $value) {