diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 94a0d131d2b3ea5c3719249130a58b17f5fc9f9e..f0952f2dcd07daa62ff4453df140a0317d7c3c33 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -480,7 +480,8 @@ class SimpleSAML_XHTML_Template {
 	// Merge two translation arrays.
 	public static function lang_merge($def, $lang) {
 		foreach($def AS $key => $value) {
-			$def[$key] = array_merge($value, $lang[$key]);
+			if (array_key_exists($key, $lang))
+				$def[$key] = array_merge($value, $lang[$key]);
 		}
 		return $def;
 	}