hasadna / alaveteli

Provide a Freedom of Information request system for your jurisdiction
http://www.askdata.org.il/
Other
2 stars 1 forks source link

Make Hebrew the default language #2

Closed yauzi closed 11 years ago

yauzi commented 11 years ago

Currently askdata.org.il opens to the English version, and the Hebrew one appears at askdata.org.il/he_IL.

crowbot commented 11 years ago

I'm guessing this is because the current config/general.yml file has a value of 'en he_IL' for the parameter AVAILABLE_LOCALES and 'en' for the parameter DEFAULT_LOCALE. You should be able make Hebrew the default language by changing the DEFAULT_LOCALE setting to 'he_IL'. If you don't want English to appear at all, you can remove it from AVAILABLE_LOCALES. If you don't want the default locale to show up in URLs, you can set the parameter INCLUDE_DEFAULT_LOCALE_IN_URLS to false too.

yehudab commented 11 years ago

@crowbot thanks for the quick reply. Unfortunately, we tried that, but this leads to an error message when trying to display the site's front page. See below the error we are getting (The Hebrew bit at the top says something like: Verification failed: PublicBody|Name already taken) Any idea on how to fix this?

Showing app/views/general/_frontpage_search_box.rhtml where line #5 raised:

האימות נכשל: PublicBody|Name השם כבר תפוס
Extracted source (around line #5):

2:   <%= _("Search over<br/>
3:   <strong>{{number_of_requests}} requests</strong> <span>and</span><br/>
4:   <strong>{{number_of_authorities}} authorities</strong>",
5:   :number_of_requests => InfoRequest.visible.count, :number_of_authorities => PublicBody.visible.count) %>
6: </h2>
7: <form id="search_form" method="post" action="<%= search_redirect_path %>">
8:   <div>
Trace of template inclusion: app/views/general/frontpage.rhtml

RAILS_ROOT: /home/yehuda/alaveteli

Application Trace | Framework Trace | Full Trace
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/validations.rb:1101:in `save_without_dirty!'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/dirty.rb:87:in `save_without_transactions!'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/transactions.rb:200:in `save!'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/transactions.rb:182:in `transaction'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/transactions.rb:200:in `save!'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/home/yehuda/alaveteli/vendor/bundle/ruby/1.8/bundler/gems/rails-c0d325a13e13/activerecord/lib/active_record/transactions.rb:200:in `save!'
/home/yehuda/alaveteli/app/models/public_body.rb:351:in `internal_admin_body'
/home/yehuda/alaveteli/app/models/public_body.rb:338:in `internal_admin_body'
/home/yehuda/alaveteli/app/models/public_body.rb:50
/home/yehuda/alaveteli/app/views/general/_frontpage_search_box.rhtml:5:in `_run_rhtml_app47views47general47_frontpage_search_box46rhtml_locals_frontpage_search_box_object'
/home/yehuda/alaveteli/app/views/general/frontpage.rhtml:9:in `_run_rhtml_app47views47general47frontpage46rhtml'
/home/yehuda/alaveteli/app/controllers/application_controller.rb:105:in `record_memory'
crowbot commented 11 years ago

Ah, I see this is caused by the code that checks to see whether the 'Internal admin body' exists, and tries to create it if it doesn't. When the default locale is changed after this body has been created, the initial query to check whether it exists returns nil as the body doesn't have a translation in the new default locale, and the code tries to create it, causing a primary key duplication error. A quick fix for this is:

After this, you should be able to change the default langauge to Hebrew and restart the instance without getting that error.

crowbot commented 11 years ago

I've also created a ticket for Alaveteli here to resolve the reliance on an English name for the internal admin body. https://github.com/mysociety/alaveteli/issues/1001

yehudab commented 11 years ago

Thanks for explaining the situation. I ended up using a slightly different work-around, which is to delete the 'Internal admin authority' while in 'en' default locale, and then restart the server with 'he_IL' default locale. This caused a new authority to be created with correct url.