Skip to content

A platform for community discussion. Free, open, simple.

FIX: HTML lang attribute expects hyphen instead of underscore

Gerhard Schlagercc851af7500b
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 046ab45f017..b26b81c939f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -177,10 +177,8 @@ module ApplicationHelper
["ar", "ur", "fa_IR", "he"].include? I18n.locale.to_s
end
- def user_locale
- locale = current_user.locale if current_user && SiteSetting.allow_user_locale
- # changing back to default shoves a blank string there
- locale.present? ? locale : SiteSetting.default_locale
+ def html_lang
+ SiteSetting.default_locale.sub("_", "-")
end
# Creates open graph and twitter card meta data
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 94bf3070370..b815383d674 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="<%= SiteSetting.default_locale %>" class="<%= html_classes %>">
+<html lang="<%= html_lang %>" class="<%= html_classes %>">
<head>
<meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>
diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb
index 98f15b0e469..4cbf2eef8df 100644
--- a/app/views/layouts/crawler.html.erb
+++ b/app/views/layouts/crawler.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="<%= SiteSetting.default_locale %>">
+<html lang="<%= html_lang %>">
<head>
<meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>
diff --git a/app/views/layouts/no_ember.html.erb b/app/views/layouts/no_ember.html.erb
index eb8c6fabdf8..8b68e33910f 100644
--- a/app/views/layouts/no_ember.html.erb
+++ b/app/views/layouts/no_ember.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="<%= SiteSetting.default_locale %>">
+<html lang="<%= html_lang %>">
<head>
<meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>
diff --git a/app/views/offline/offline.html.erb b/app/views/offline/offline.html.erb
index 8e3115986a8..3c6d870fb97 100644
--- a/app/views/offline/offline.html.erb
+++ b/app/views/offline/offline.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= SiteSetting.default_locale %>" xml:lang="<%= SiteSetting.default_locale %>">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= html_lang %>" xml:lang="<%= html_lang %>">
<head>
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
diff --git a/app/views/topics/plain.html.erb b/app/views/topics/plain.html.erb
index 52d6d5cbdbc..25531cb837d 100644
--- a/app/views/topics/plain.html.erb
+++ b/app/views/topics/plain.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="<%=SiteSetting.default_locale%>">
+<html lang="<%= html_lang %>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= @topic_view.topic.title %></title>
diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb
index de8e805c8d4..71ebed0cb32 100644
--- a/app/views/user_notifications/digest.html.erb
+++ b/app/views/user_notifications/digest.html.erb
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= html_lang %>" xml:lang="<%= html_lang %>">
<head>
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">