FIX: HTML lang attribute expects hyphen instead of underscore

This commit is contained in:
Gerhard Schlager 2018-08-20 13:55:58 +02:00
parent 14af90df5b
commit cc851af750
7 changed files with 8 additions and 10 deletions

View File

@ -177,10 +177,8 @@ module ApplicationHelper
["ar", "ur", "fa_IR", "he"].include? I18n.locale.to_s ["ar", "ur", "fa_IR", "he"].include? I18n.locale.to_s
end end
def user_locale def html_lang
locale = current_user.locale if current_user && SiteSetting.allow_user_locale SiteSetting.default_locale.sub("_", "-")
# changing back to default shoves a blank string there
locale.present? ? locale : SiteSetting.default_locale
end end
# Creates open graph and twitter card meta data # Creates open graph and twitter card meta data

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%= SiteSetting.default_locale %>" class="<%= html_classes %>"> <html lang="<%= html_lang %>" class="<%= html_classes %>">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title> <title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%= SiteSetting.default_locale %>"> <html lang="<%= html_lang %>">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title> <title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%= SiteSetting.default_locale %>"> <html lang="<%= html_lang %>">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title> <title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!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> <head>
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width"> <meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%=SiteSetting.default_locale%>"> <html lang="<%= html_lang %>">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= @topic_view.topic.title %></title> <title><%= @topic_view.topic.title %></title>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!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> <head>
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width"> <meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">