Set html lang based on selected locale
Set html lang based on selected locale

--- a/include/Resource.class.php
+++ b/include/Resource.class.php
@@ -100,6 +100,21 @@
 	public function GetLocale()
 	{
 		return $this->locale;
+	}
+
+	/**
+	 * Gets the currently instantiated primary locale
+	 *
+	 * @return string primary locale identifier
+	 */
+	public function GetPrimaryLocale()
+	{
+		$locale = $this->locale;
+		$underscore = strpos($locale, '_');
+		if ($underscore !== false) {
+			$locale = substr($locale, 0, $underscore);
+		}
+		return $locale;
 	}
 
 	/**

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -502,9 +502,11 @@
 			$this->tpl->assign('searchtype', $this->params['searchtype']);
 		if ($this->resource) {
 			$this->tpl->assign('currentlocale', $this->resource->GetLocale());
+			$this->tpl->assign('currentprimarylocale', $this->resource->GetPrimaryLocale());
 			$this->tpl->assign('resource', $this->resource);
 		} else {
 			$this->tpl->assign('currentlocale', 'en_US');
+			$this->tpl->assign('currentprimarylocale', 'en');
 		}
 		$this->tpl->assign('supportedlocales', GitPHP_Resource::SupportedLocales(true));
 		if ($this->config->GetValue('graphs'))

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -9,7 +9,7 @@
  * @subpackage Template
  *}
 <!DOCTYPE html>
-<html>
+<html lang="{$currentprimarylocale}">
   <!-- gitphp web interface {$version}, (C) 2006-2011 Christopher Han <xiphux@gmail.com> -->
   <head>
     <title>

comments