##// END OF EJS Templates
set html lang by user locale (#14206)...
Toshi MARUYAMA -
r11722:ebb73fa258db
parent child
Show More
@@ -1,80 +1,80
1 <!DOCTYPE html>
1 <!DOCTYPE html>
2 <html lang="en">
2 <html lang="<%= current_language %>">
3 <head>
3 <head>
4 <meta charset="utf-8" />
4 <meta charset="utf-8" />
5 <title><%=h html_title %></title>
5 <title><%=h html_title %></title>
6 <meta name="description" content="<%= Redmine::Info.app_name %>" />
6 <meta name="description" content="<%= Redmine::Info.app_name %>" />
7 <meta name="keywords" content="issue,bug,tracker" />
7 <meta name="keywords" content="issue,bug,tracker" />
8 <%= csrf_meta_tag %>
8 <%= csrf_meta_tag %>
9 <%= favicon %>
9 <%= favicon %>
10 <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
10 <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
11 <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
11 <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
12 <%= javascript_heads %>
12 <%= javascript_heads %>
13 <%= heads_for_theme %>
13 <%= heads_for_theme %>
14 <%= call_hook :view_layouts_base_html_head %>
14 <%= call_hook :view_layouts_base_html_head %>
15 <!-- page specific tags -->
15 <!-- page specific tags -->
16 <%= yield :header_tags -%>
16 <%= yield :header_tags -%>
17 </head>
17 </head>
18 <body class="<%=h body_css_classes %>">
18 <body class="<%=h body_css_classes %>">
19 <div id="wrapper">
19 <div id="wrapper">
20 <div id="wrapper2">
20 <div id="wrapper2">
21 <div id="wrapper3">
21 <div id="wrapper3">
22 <div id="top-menu">
22 <div id="top-menu">
23 <div id="account">
23 <div id="account">
24 <%= render_menu :account_menu -%>
24 <%= render_menu :account_menu -%>
25 </div>
25 </div>
26 <%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
26 <%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
27 <%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%>
27 <%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%>
28 </div>
28 </div>
29
29
30 <div id="header">
30 <div id="header">
31 <% if User.current.logged? || !Setting.login_required? %>
31 <% if User.current.logged? || !Setting.login_required? %>
32 <div id="quick-search">
32 <div id="quick-search">
33 <%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
33 <%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
34 <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
34 <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
35 <label for='q'>
35 <label for='q'>
36 <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
36 <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
37 </label>
37 </label>
38 <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
38 <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
39 <% end %>
39 <% end %>
40 <%= render_project_jump_box %>
40 <%= render_project_jump_box %>
41 </div>
41 </div>
42 <% end %>
42 <% end %>
43
43
44 <h1><%= page_header_title %></h1>
44 <h1><%= page_header_title %></h1>
45
45
46 <% if display_main_menu?(@project) %>
46 <% if display_main_menu?(@project) %>
47 <div id="main-menu">
47 <div id="main-menu">
48 <%= render_main_menu(@project) %>
48 <%= render_main_menu(@project) %>
49 </div>
49 </div>
50 <% end %>
50 <% end %>
51 </div>
51 </div>
52
52
53 <div id="main" class="<%= sidebar_content? ? '' : 'nosidebar' %>">
53 <div id="main" class="<%= sidebar_content? ? '' : 'nosidebar' %>">
54 <div id="sidebar">
54 <div id="sidebar">
55 <%= yield :sidebar %>
55 <%= yield :sidebar %>
56 <%= view_layouts_base_sidebar_hook_response %>
56 <%= view_layouts_base_sidebar_hook_response %>
57 </div>
57 </div>
58
58
59 <div id="content">
59 <div id="content">
60 <%= render_flash_messages %>
60 <%= render_flash_messages %>
61 <%= yield %>
61 <%= yield %>
62 <%= call_hook :view_layouts_base_content %>
62 <%= call_hook :view_layouts_base_content %>
63 <div style="clear:both;"></div>
63 <div style="clear:both;"></div>
64 </div>
64 </div>
65 </div>
65 </div>
66 </div>
66 </div>
67
67
68 <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
68 <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
69 <div id="ajax-modal" style="display:none;"></div>
69 <div id="ajax-modal" style="display:none;"></div>
70
70
71 <div id="footer">
71 <div id="footer">
72 <div class="bgl"><div class="bgr">
72 <div class="bgl"><div class="bgr">
73 Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; 2006-2013 Jean-Philippe Lang
73 Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; 2006-2013 Jean-Philippe Lang
74 </div></div>
74 </div></div>
75 </div>
75 </div>
76 </div>
76 </div>
77 </div>
77 </div>
78 <%= call_hook :view_layouts_base_body_bottom %>
78 <%= call_hook :view_layouts_base_body_bottom %>
79 </body>
79 </body>
80 </html>
80 </html>
@@ -1,67 +1,70
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class ApplicationTest < ActionController::IntegrationTest
20 class ApplicationTest < ActionController::IntegrationTest
21 include Redmine::I18n
21 include Redmine::I18n
22
22
23 fixtures :projects, :trackers, :issue_statuses, :issues,
23 fixtures :projects, :trackers, :issue_statuses, :issues,
24 :enumerations, :users, :issue_categories,
24 :enumerations, :users, :issue_categories,
25 :projects_trackers,
25 :projects_trackers,
26 :roles,
26 :roles,
27 :member_roles,
27 :member_roles,
28 :members,
28 :members,
29 :enabled_modules
29 :enabled_modules
30
30
31 def test_set_localization
31 def test_set_localization
32 Setting.default_language = 'en'
32 Setting.default_language = 'en'
33
33
34 # a french user
34 # a french user
35 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
35 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
36 assert_response :success
36 assert_response :success
37 assert_tag :tag => 'h2', :content => 'Projets'
37 assert_tag :tag => 'h2', :content => 'Projets'
38 assert_equal :fr, current_language
38 assert_equal :fr, current_language
39 assert_select "html[lang=?]", "fr"
39
40
40 # then an italien user
41 # then an italien user
41 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
42 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
42 assert_response :success
43 assert_response :success
43 assert_tag :tag => 'h2', :content => 'Progetti'
44 assert_tag :tag => 'h2', :content => 'Progetti'
44 assert_equal :it, current_language
45 assert_equal :it, current_language
46 assert_select "html[lang=?]", "it"
45
47
46 # not a supported language: default language should be used
48 # not a supported language: default language should be used
47 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
49 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
48 assert_response :success
50 assert_response :success
49 assert_tag :tag => 'h2', :content => 'Projects'
51 assert_tag :tag => 'h2', :content => 'Projects'
52 assert_select "html[lang=?]", "en"
50 end
53 end
51
54
52 def test_token_based_access_should_not_start_session
55 def test_token_based_access_should_not_start_session
53 # issue of a private project
56 # issue of a private project
54 get 'issues/4.atom'
57 get 'issues/4.atom'
55 assert_response 302
58 assert_response 302
56
59
57 rss_key = User.find(2).rss_key
60 rss_key = User.find(2).rss_key
58 get "issues/4.atom?key=#{rss_key}"
61 get "issues/4.atom?key=#{rss_key}"
59 assert_response 200
62 assert_response 200
60 assert_nil session[:user_id]
63 assert_nil session[:user_id]
61 end
64 end
62
65
63 def test_missing_template_should_respond_with_404
66 def test_missing_template_should_respond_with_404
64 get '/login.png'
67 get '/login.png'
65 assert_response 404
68 assert_response 404
66 end
69 end
67 end
70 end
General Comments 0
You need to be logged in to leave comments. Login now