languages are set from the dropdown, adding configs
Oleg
committed Jun 25, 2011
commit ad72f6ee6cebcaac9d9043b48953e824db458f92
Showing 7
changed files with
35 additions
and 4 deletions
app/controllers/cms_admin/sites_controller.rb
+1
-0
| @@ | @@ -52,6 +52,7 @@ protected |
| def load_site | |
| @site = Cms::Site.find(params[:id]) | |
| + | I18n.locale = @site.locale |
| rescue ActiveRecord::RecordNotFound | |
| flash[:error] = I18n.t('cms.sites.not_found') | |
| redirect_to :action => :index | |
app/views/cms_admin/sites/_form.html.erb
+1
-1
| @@ | @@ -1,7 +1,7 @@ |
| <%= form.text_field :label %> | |
| <%= form.text_field :hostname %> | |
| <%= form.text_field :path %> | |
| - | <%= form.text_field :locale %> |
| + | <%= form.select :locale, ComfortableMexicanSofa.config.locales.to_a.collect{|l| [l[1], l[0]]} %> |
| <%= form.check_box :is_mirrored %> | |
| <%= form.simple_field nil, nil, :class => 'submit_element' do %> | |
config/initializers/comfortable_mexican_sofa.rb
+10
-0
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| ComfortableMexicanSofa.configure do |config| | |
| # Title of the admin area | |
| # config.cms_title = 'ComfortableMexicanSofa MicroCMS' | |
| @@ | @@ -39,6 +41,14 @@ ComfortableMexicanSofa.configure do |config| |
| # object you want to keep. Set it to 0 if you wish to turn this feature off. | |
| # config.revisions_limit = 25 | |
| + | # Locale definitions. If you want to define your own locale merge |
| + | # {:locale => 'Locale Title'} with this. |
| + | # config.locales = {:en => 'English', :es => 'Español'} |
| + | |
| + | # Admin interface will respect the locale of the site being managed. However you can |
| + | # force it to English by setting this to `:en` |
| + | # cofig.admin_locale = nil |
| + | |
| end | |
| # Default credentials for ComfortableMexicanSofa::HttpAuth | |
config/locales/en.yml
+2
-0
| @@ | @@ -15,6 +15,8 @@ en: |
| attributes: | |
| cms/site: | |
| hostname: Hostname | |
| + | path: Path |
| + | locale: Language |
| is_mirrored: Mirrored | |
| cms/layout: | |
| label: Layout Name | |
config/locales/es.yml
+3
-1
| @@ | @@ -15,7 +15,9 @@ es: |
| attributes: | |
| cms/site: | |
| hostname: Dirección | |
| - | is_mirrored: Mirrored |
| + | path: Ruta |
| + | locale: Lengua |
| + | is_mirrored: Espejo |
| cms/layout: | |
| label: Nombre de Plantilla | |
| app_layout: Plantilla Base | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+14
-2
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| class ComfortableMexicanSofa::Configuration | |
| # Don't like Comfortable Mexican Sofa? Set it to whatever you like. :( | |
| @@ | @@ -10,8 +12,8 @@ class ComfortableMexicanSofa::Configuration |
| # You can change 'cms-admin' to 'admin', for example. | |
| attr_accessor :admin_route_prefix | |
| - | # /cms-admin redirects to /cms-admin/pages but you can change it |
| - | # to something else |
| + | # When arriving at /cms-admin you may chose to redirect to arbirtary path, |
| + | # for example '/cms-admin/users' |
| attr_accessor :admin_route_redirect | |
| # Not allowing irb code to be run inside page content. False by default. | |
| @@ | @@ -30,6 +32,14 @@ class ComfortableMexicanSofa::Configuration |
| # Number of revisions kept. Default is 25. If you wish to disable: set this to 0. | |
| attr_accessor :revisions_limit | |
| + | # Locale definitions. If you want to define your own locale merge |
| + | # {:locale => 'Locale Title'} with this. |
| + | attr_accessor :locales |
| + | |
| + | # Admin interface will respect the locale of the site being managed. However you can |
| + | # force it to English by setting this to `:en` |
| + | attr_accessor :admin_locale |
| + | |
| # Configuration defaults | |
| def initialize | |
| @cms_title = 'ComfortableMexicanSofa MicroCMS' | |
| @@ | @@ -43,6 +53,8 @@ class ComfortableMexicanSofa::Configuration |
| @enable_fixtures = false | |
| @fixtures_path = File.expand_path('db/cms_fixtures', Rails.root) | |
| @revisions_limit = 25 | |
| + | @locales = { :en => 'English', :es => 'Español' } |
| + | @admin_locale = nil |
| end | |
| end | |
test/unit/configuration_test.rb
+4
-0
| @@ | @@ -1,3 +1,5 @@ |
| + | # encoding: utf-8 |
| + | |
| require File.expand_path('../test_helper', File.dirname(__FILE__)) | |
| class ConfigurationTest < ActiveSupport::TestCase | |
| @@ | @@ -12,6 +14,8 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal false, config.enable_fixtures | |
| assert_equal File.expand_path('db/cms_fixtures', Rails.root), config.fixtures_path | |
| assert_equal 25, config.revisions_limit | |
| + | assert_equal ({:en => 'English', :es => 'Español'}), config.locales |
| + | assert_equal nil, config.admin_locale |
| end | |
| def test_initialization_overrides | |