Commit 660411f45eb5c57839bc281540d7b36f62d1ef1a
1 parent
ce7e0d21
Exists in
master
and in
29 other branches
ActionItem882: putting current language in HTML header
Showing
4 changed files
with
18 additions
and
1 deletions
Show diff stats
app/helpers/language_helper.rb
app/views/layouts/application.rhtml
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2 | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>"> | |
3 | 3 | <head> |
4 | 4 | <title> |
5 | 5 | <%= @environment.name() %> | ... | ... |
test/integration/locale_setting_test.rb
... | ... | @@ -64,6 +64,14 @@ class LocaleSettingTest < ActionController::IntegrationTest |
64 | 64 | |
65 | 65 | end |
66 | 66 | |
67 | + should 'put current language in HTML headers' do | |
68 | + get '/', :lang => 'pt_BR' | |
69 | + assert_tag :tag => 'html', :attributes => { 'xml:lang' => 'pt-br', 'lang' => 'pt-br' } | |
70 | + | |
71 | + get '/', :lang => 'en' | |
72 | + assert_tag :tag => 'html', :attributes => { 'xml:lang' => 'en', 'lang' => 'en' } | |
73 | + end | |
74 | + | |
67 | 75 | protected |
68 | 76 | |
69 | 77 | def assert_locale(locale) | ... | ... |
test/unit/language_helper_test.rb
... | ... | @@ -18,6 +18,11 @@ class LanguageHelperTest < Test::Unit::TestCase |
18 | 18 | assert_equal 'pt_br', tinymce_language |
19 | 19 | end |
20 | 20 | |
21 | + should 'downcase and use dash for HTML language' do | |
22 | + self.expects(:language).returns('pt_BR') | |
23 | + assert_equal 'pt-br', html_language | |
24 | + end | |
25 | + | |
21 | 26 | should 'generate language chooser correcly' do |
22 | 27 | Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once |
23 | 28 | ... | ... |