Permalink
Browse files

Introduce "lang" parameter for a Site. Used in feed.rxml to specify f…

…eed language, especially useful for non-english blogs.

Site settings form altered.
  • Loading branch information...
1 parent f80afaf commit bc58c2c800ee1bb8e33b4054e8565ce7e19ee8fa @yaroslav yaroslav committed May 11, 2008
Showing with 15 additions and 1 deletion.
  1. +5 −0 app/views/admin/settings/index.rhtml
  2. +1 −1 app/views/feed/feed.rxml
  3. +9 −0 db/migrate/076_add_lang_to_sites.rb
@@ -31,6 +31,11 @@
<dt><label for="site_timezone">Website Timezone</label></dt>
<dd><%= select_tag 'site_timezone', options_for_select(['UTC'] + TZInfo::Timezone.all.map{|tz| [tz.to_s, tz.name]}.sort, @site.timezone.name), :name => 'site[timezone]' %></dd>
<dt>
+ <label for="site_lang">Site language</label>
+ <span class="hint">Used to specify language in your site feeds</span>
+ </dt>
+ <dd><%= f.text_field :lang %></dd>
+ <dt>
<label for="site_current_theme_path">Current Theme Path</label>
<span class="hint">This is the path to the current template in /themes/site-<%= site.id %>. Be careful with this setting!</span>
</dt>
View
@@ -1,6 +1,6 @@
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
-xml.feed "xml:lang" => "en-US", "xmlns" => 'http://www.w3.org/2005/Atom' do
+xml.feed "xml:lang" => "#{site.lang || 'en-US'}", "xmlns" => 'http://www.w3.org/2005/Atom' do
xml.title "#{site.title || 'Mephisto'} - #{@section ? @section.name : 'All'}#{' Comments' if @comments && @articles.nil?}"
xml.id "tag:#{request.host},#{Time.now.utc.year}:mephisto#{"/#{@section.path}" if @section}#{ '/comments' if @comments && @articles.nil?}"
xml.generator "Mephisto #{Mephisto::Version::TITLE}", :uri => "http://mephistoblog.com", :version => "#{Mephisto::Version::STRING}"
@@ -0,0 +1,9 @@
+class AddLangToSites < ActiveRecord::Migration
+ def self.up
+ add_column :sites, :lang, :string, :null => false, :default => 'en-US'
+ end
+
+ def self.down
+ remove_column :sites, :lang
+ end
+end

3 comments on commit bc58c2c

TomK32 commented on bc58c2c Jun 5, 2008

looks like :lang is missing in bootstrap.

TomK32, thanks for noticing, need to update schema.rb, but getting weird table removals atm..

Well, running db:migrate on fresh mephisto for me deletes “feedbacks” table all the time, not sure if this is intended.

Please sign in to comment.