Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 4099 add a preference for the preferred locale for a user. #1866

Merged
merged 40 commits into from
May 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c6668cc
Add fields for locales to allow emails to be sent and the user interf…
zz9pzza Oct 3, 2014
756b9c7
Make test not go bang
zz9pzza Oct 3, 2014
89d8037
The ability to change the prefered locale is now controlled by roll out
zz9pzza Oct 4, 2014
da94fdf
If the user has a locale preference then honor it in the FAQ's
zz9pzza Oct 4, 2014
34fe64d
remove debugging code
zz9pzza Oct 4, 2014
4367bd5
Make the preference visible in the testing enviroment
zz9pzza Oct 5, 2014
8be49cf
Update text used in label
zz9pzza Oct 5, 2014
fdecc60
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza Nov 6, 2014
29347a2
Merge branch 'issue_4099' of git://github.com/zz9pzza/otwarchive into…
sarken Nov 16, 2014
1c09f7e
4099 Locales front end suggestions
sarken Nov 17, 2014
753b43f
Following Sarken's comments
zz9pzza Nov 18, 2014
ad92811
Merge branch 'issue_4099' of https://github.com/sarken/otwarchive int…
zz9pzza Nov 18, 2014
fb64249
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza Nov 18, 2014
b68ac08
I think that is what saren wished
zz9pzza Nov 21, 2014
9277259
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza Nov 21, 2014
26bbffd
fix merge conflict
zz9pzza Nov 21, 2014
f7ebf13
opening in <li> removed
zz9pzza Nov 21, 2014
d1453a3
fix from Sarken
zz9pzza Nov 21, 2014
6ffc135
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza Jan 11, 2015
d04cac4
Listen to the hound
zz9pzza Jan 11, 2015
c21c43b
Fix conflict
zz9pzza Apr 26, 2015
3e6d0f0
Follow the hound
zz9pzza Apr 26, 2015
6e8c6db
language not l
zz9pzza Apr 30, 2015
2c6788f
Fix spaces
zz9pzza Apr 30, 2015
9c26565
s/L/l/;
zz9pzza Apr 30, 2015
4056207
locale not l
zz9pzza Apr 30, 2015
07080f2
Change the text
zz9pzza Apr 30, 2015
81d76a7
Clear up tests
zz9pzza Apr 30, 2015
066f36d
preferred not prefered
zz9pzza Apr 30, 2015
ccfd466
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza May 3, 2015
f6cecc3
One last typo
zz9pzza May 6, 2015
e5754af
Ensure the database is correct
zz9pzza May 7, 2015
9e4509c
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
zz9pzza May 7, 2015
d45b418
Update the sructure
zz9pzza May 7, 2015
cbc201e
Put the db files back
zz9pzza May 8, 2015
f72f979
Get travis to delete the current db state to make the files not used …
zz9pzza May 8, 2015
a38edb4
Try this travis
zz9pzza May 8, 2015
4f9b118
Try this travis
zz9pzza May 8, 2015
826804a
We need to do the migrations
zz9pzza May 8, 2015
8e6c0c8
Roll up the migrations properly
zz9pzza May 9, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ services:
- redis-server
- memcached
script:
- bundle exec rake db:create:all --trace
- bundle exec rake db:schema:load --trace
- rm -f structure.sql
- RAILS_ENV=test bundle exec rake db:create:all --trace
- RAILS_ENV=test bundle exec rake db:schema:load --trace
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec $TEST_GROUP
before_script:
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/archive_faqs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def set_locale
if params[:language_id] && session[:language_id] != params[:language_id]
session[:language_id] = params[:language_id]
end
@i18n_locale = session[:language_id] || I18n.default_locale
if current_user.present? && $rollout.active?(:set_locale_preference, current_user)
@i18n_locale = session[:language_id] || Locale.find(current_user.preference.preferred_locale).iso
else
@i18n_locale = session[:language_id] || I18n.default_locale
end
end

def require_language_id
Expand Down
1 change: 1 addition & 0 deletions app/controllers/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
@user = User.find_by_login(params[:user_id])
@preference = @user.preference || Preference.create(:user_id => @user.id)
@available_skins = (current_user.skins.site_skins + Skin.approved_skins.site_skins).uniq
@available_locales = Locale.where(email_enabled: true)
end

def update
Expand Down
2 changes: 0 additions & 2 deletions app/models/locale.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class Locale < ActiveRecord::Base
belongs_to :language
# has_many :translations
# has_many :translation_notes
validates_presence_of :iso
validates_uniqueness_of :iso
validates_presence_of :name
Expand Down
32 changes: 32 additions & 0 deletions app/views/locales/_locale_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<%= form_for(@locale, html: { class: 'post' }) do |f| %>
<p class="required notice">* <%= t('.required_notice', :default => "Required information") %></p>

<fieldset>
<legend><%= t('.locale_legend', :default => "Locale") %></legend>
<h3 class="landmark heading"><%= t('.locale_heading', :default => "Locale") %></h3>
<dl>
<dt class="required"><%= f.label :name, t('.name', :default => "Name") + '*' %></dt>
<dd class="required"><%= f.text_field :name %></dd>

<dt class="required"><%= f.label :iso, t('.iso', :default => "ISO code") + '*' %></dt>
<dd class="required"><%= f.text_field :iso %></dd>

<dt class="required"><%= f.label :language_id, t('.language', :default => "Language") + '*' %></dt>
<dd class="required"><%= f.select(:language_id, @languages.collect { |language| [ language.name, language.id ] }) %></dd>

<dt><%= f.check_box :email_enabled %></dt>
<dd><%= f.label :email_enabled, t('.enable_email', :default => "Use this locale to send email") %></dd>

<dt><%= f.check_box :interface_enabled %></dt>
<dd><%= f.label :interface_enabled, t('.enable_interface', :default => "Use this locale for the interface") %></dd>

</dl>
</fieldset>
<fieldset>
<legend><%= t('.actions_legend', :default => "Actions") %></legend>
<h3 class="landmark heading"><%= t('.actions_heading', :default => "Actions") %></h3>
<p class="submit actions">
<%= f.submit @locale.new_record? ? t('.create_button', :default => "Create Locale") : t('.edit_button', :default => "Update Locale") %>
</p>
</fieldset>
<% end %>
4 changes: 4 additions & 0 deletions app/views/locales/_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ul class="navigation actions" role="navigation">
<li><%= span_if_current t('.link_to_index', :default => 'Locales'), locales_path %></li>
<li><%= span_if_current t('.link_to_new', :default => 'New Locale'), new_locale_path %></li>
</ul>
15 changes: 3 additions & 12 deletions app/views/locales/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= t('.edit_locale', :default => 'Edit a locale:') %></h2>
<h2 class="heading"><%= t('.edit_locale', :default => 'Edit Locale') %></h2>
<%= error_messages_for :locale %>
<!--/descriptions-->

<!--subnav-->
<%= render 'navigation' %>
<!--/subnav-->

<!--main content-->
<%= form_for(@locale) do |f| %>
<dl>
<dt><%= f.label :language_id, t('.language', :default => "Language:") %></dt>
<dd><%= f.select(:language_id, @languages.collect {|l| [ l.name, l.id ] }) %></dd>
<dt><%= f.label :name, t('.name', :default => "Name:") %></dt>
<dd><%= f.text_field :name %></dd>
<dt><%= f.label :iso, t('.iso', :default => "Iso:") %></dt>
<dd><%= f.text_field :iso %></dd>
</dl>
<p class="submit actions"><%= f.submit t('.forms.submit', :default => "Submit") %></p>
<% end %>
<%= render 'locale_form' %>
<!--/content-->

54 changes: 32 additions & 22 deletions app/views/locales/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= t('.supported_locales', :default => 'The archive supports the following locales:') %></h2>
<h2 class="heading"><%= t('.supported_locales', :default => 'Supported Locales') %></h2>
<!--/descriptions-->

<!--main content-->
<% if logged_in_as_admin? || permit?("translation_admin") %>
<p>
<%= link_to t('.link_to_new', :default => 'Add a new one'), new_locale_path %>
</p>
<!--main content-->
<h3 class="landmark heading">List of Locales</h3>
<table summary="Locales">
<caption>Locales</caption>
<% if logged_in_as_admin? || permit?("translation_admin") %>
<%= render 'navigation' %>
<!--main content-->
<table summary="<%= t('.locale_table_summary', :default => 'Lists supported locales, along with details of how they are used and options to modify them.') %>">
<caption><%= t('.locale_table_caption', :default => 'Supported Locales') %></caption>
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Name</th>
<th scope="col">ISO code</th>
<th scope="col">Primary locale</th>
<th scope="col">ISO Code</th>
<th scope="col">Primary Locale</th>
<th scope="col">Use for Email</th>
<th scope="col">Use for Interface</th>
<th scope="col">Created at</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<% for locale in @locales %>
<tr> <td><%= link_to ts('Edit'), {controller: :locales, action: :edit, id: locale.iso} %></td><td><%= locale.name %></td><td><%=locale.iso%></td><td><%=locale.main%></td><td><%=locale.updated_at%></td></tr>
<% end %>
<% for locale in @locales %>
<tr>
<th scope="row"><%= locale.name %></th>
<td><%= locale.iso %></td>
<td><%= locale.main %></td>
<td><%= locale.email_enabled %></td>
<td><%= locale.interface_enabled %></td>
<td><%= locale.updated_at %></td>
<td class="actions">
<%= link_to ts('Edit'), {controller: :locales, action: :edit, id: locale.iso} %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a remaining ts() in a file that seems to otherwise use t()

</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<ul>
<% for locale in @locales %>
<li><%= locale.name%></li>
<% end %>
</ul>
<%= link_to t('.suggest_locale', :default => 'Suggest a new one!'), new_feedback_report_path %>
<ul>
<% for locale in @locales %>
<li><%= locale.name %></li>
<% end %>
</ul>
<p class="navigation actions" role="navigation">
<%= link_to t('.suggest_locale', :default => 'Suggest a Locale!'), new_feedback_report_path %>
</p>
<% end %>

<!--/content-->

<!--subnav-->
Expand Down
17 changes: 3 additions & 14 deletions app/views/locales/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= t('.add_new_locale', :default => 'Add a new locale:') %></h2>
<h2 class="heading"><%= t('.add_new_locale', :default => 'New Locale') %></h2>
<%= error_messages_for :locale %>
<!--/descriptions-->

<!--subnav-->
<%= render 'navigation' %>
<!--/subnav-->

<!--main content-->
<%= form_for(@locale) do |f| %>
<dl>
<dt><%= f.label :language_id, t('.language', :default => "Language:") %></dt>
<dd><%= f.select(:language_id, @languages.collect {|l| [ l.name, l.id ] }) %></dd>

<dt><%= f.label :name, t('.name', :default => "Name:") %></dt>
<dd><%= f.text_field :name %></dd>

<dt><%= f.label :iso, t('.iso', :default => "Iso:") %></dt>
<dd><%= f.text_field :iso %></dd>
</dl>
<p class="submit actions"><%= f.submit t('.forms.submit', :default => "Submit") %></p>
<% end %>
<%= render 'locale_form' %>
<!--/content-->

37 changes: 20 additions & 17 deletions app/views/preferences/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,31 @@
<%= f.check_box :hide_freeform %>
<%= f.label :hide_freeform, ts('Hide additional tags (you can still choose to show them).') %>
</li>

<li>
<%= f.check_box :disable_work_skins %>
<%= f.label :disable_work_skins, ts('Hide work skins (you can still choose to show them).') %> <%= link_to_help 'skins-basics' %>
</li>
</ul>

<fieldset>
<dl>
<dt><%= f.label :skin_id, ts('Your site skin')%> <%= link_to_help 'skins-basics' %>:</dt>
<dd>
<span class="actions"><%= link_to ts('Public Site Skins'), skins_path %></span>
<%= f.select :skin_id, @available_skins.collect{|s| [s.title, s.id]} %>
</dd>

<dt><%= f.label :time_zone, ts('Your time zone: ')%></dt>
<dd><%= f.time_zone_select :time_zone, nil, :default => Time.zone.name %></dd>

<dt><%= f.label :work_title_format, ts('Browser page title format') %> <%= link_to_help 'work_title_format' %>:</dt>
<dd><%= f.text_field :work_title_format %></dd>
</dl>
</fieldset>
</fieldset>
<fieldset>
<dl>
<dt><%= f.label :skin_id, ts('Your site skin') %> <%= link_to_help 'skins-basics' %>:</dt>
<dd>
<span class="actions"><%= link_to ts('Public Site Skins'), skins_path %></span>
<%= f.select :skin_id, @available_skins.collect{|s| [s.title, s.id]} %>
</dd>

<dt><%= f.label :time_zone, ts('Your time zone: ') %></dt>
<dd><%= f.time_zone_select :time_zone, nil, :default => Time.zone.name %></dd>

<% if Rails.env.test? || Rails.env.development? || $rollout.active?(:set_locale_preference, @user) %>
<dt><%= f.label :preferred_locale, ts('Your locale')%> <%= link_to_help 'locale-preferences' %></dt>
<dd><%= f.select :preferred_locale, @available_locales.collect{|locale| [locale.name, locale.id]}, :default => @preference.preferred_locale %></dd>
<% end %>

<dt><%= f.label :work_title_format, ts('Browser page title format') %> <%= link_to_help 'work_title_format' %>:</dt>
<dd><%= f.text_field :work_title_format %></dd>
</dl>
</fieldset>

<fieldset>
Expand Down

This file was deleted.

86 changes: 0 additions & 86 deletions db/migrate/20101015053927_add_sanitizer_version_fields.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrate/20101016131743_add_inherited_to_filter_taggings.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrate/20101022002353_add_tag_wrangling_freeze.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/migrate/20101022160603_add_restrict_to_fandom_to_tag_set.rb

This file was deleted.

Loading