subdomain_locale 1.0.beta5 → 1.0.beta6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 749e76f7ece9b06223186583b7d207e557b37a40
4
- data.tar.gz: 1b9cc4610f7e450943c8a06179855241a0cd0476
3
+ metadata.gz: 451e8afface6f75567cd9c4057f06dece6963bb5
4
+ data.tar.gz: a3f9bb42af3d2e191da53ab0b0c938d6361135ca
5
5
  SHA512:
6
- metadata.gz: 9bab89ac779f0173ef5e41eb3ad49210cd849799fc72ace8a02bfa055f51148e1b06a175187773e28d6737c87a3047de69953f916b91ffadd5f81a24efa53f0c
7
- data.tar.gz: 63c464a9cc6e82aa08892a4b7feba3535d046d6f8b8035d26e9bd5248cf9c6e6d289a97323a7de3b43ac74abf749b88fce8882df2b555a0502d65ff1b7cd2cdc
6
+ metadata.gz: e51dfa3412c056bb4f037440758b8be1cfaa45ebccd02cbd178ce770b76ebccee944569e0b54bab7a8adf12e2ad541d6ad60327c6be5ede32dd5cbf47938b3e8
7
+ data.tar.gz: 1d36125d9dc0a122e0dbb90efa24ef61f7395f569464b770f291d84f4ada319b7ab4f63a709ccfc4a5b54aa01700eb56df755d93d7830870b9eeafdfdbc431ea
@@ -1,13 +1,13 @@
1
1
  module SubdomainLocale
2
2
  class << self
3
- attr_accessor :mapping
3
+ attr_accessor :mapping, :default_locale
4
4
  end
5
5
 
6
6
  def self.default_fallback(locale)
7
7
  if I18n.locale_available?(locale)
8
8
  locale
9
9
  else
10
- I18n.default_locale
10
+ default_locale
11
11
  end
12
12
  end
13
13
 
@@ -3,12 +3,15 @@ require "rails/railtie"
3
3
  module SubdomainLocale
4
4
  class Railtie < ::Rails::Railtie
5
5
  config.subdomain_locale = {}
6
- config.subdomain_default = "" # or "www"
6
+ config.default_subdomain = "" # or "www"
7
+ config.default_locale = nil
7
8
 
8
9
  # Execute after all application initializers, I18n is often configured there.
9
10
  config.after_initialize do |app|
10
11
  require "subdomain_locale/mapping"
11
- default = { app.config.subdomain_default => I18n.default_locale }
12
+ SubdomainLocale.default_locale = app.config.default_locale || I18n.default_locale
13
+
14
+ default = { app.config.default_subdomain => SubdomainLocale.default_locale }
12
15
  mapping = default.merge(app.config.subdomain_locale)
13
16
  SubdomainLocale.mapping = Mapping.new(mapping)
14
17
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "subdomain_locale"
5
- spec.version = "1.0.beta5"
5
+ spec.version = "1.0.beta6"
6
6
  spec.authors = ["Semyon Perepelitsa"]
7
7
  spec.email = ["sema@sema.in"]
8
8
  spec.summary = "Set I18n locale based on subdomain"
@@ -5,8 +5,9 @@ require "subdomain_locale/railtie"
5
5
  module Dummy
6
6
  class Application < Rails::Application
7
7
  config.i18n.enforce_available_locales = true
8
- config.i18n.default_locale = :en
9
8
  config.i18n.available_locales = :en, :ru, :uk
9
+
10
+ config.default_locale = :ru
10
11
  config.subdomain_locale["ua"] = :uk
11
12
 
12
13
  config.secret_key_base = '-'
data/test/rails_test.rb CHANGED
@@ -7,8 +7,8 @@ class HelloControllerTest < ActionController::TestCase
7
7
  get :world
8
8
  menu = css_select("menu a")
9
9
  assert_equal "/", menu[0]["href"]
10
- assert_equal "http://example.com/", menu[1]["href"]
11
- assert_equal "http://ru.example.com/", menu[2]["href"]
10
+ assert_equal "http://en.example.com/", menu[1]["href"]
11
+ assert_equal "http://example.com/", menu[2]["href"]
12
12
  assert_equal "http://ua.example.com/", menu[3]["href"]
13
13
  assert_equal "http://beta.example.com/", menu[4]["href"]
14
14
  end
@@ -17,14 +17,14 @@ class HelloControllerTest < ActionController::TestCase
17
17
  @request.host = "example.com"
18
18
  get :world
19
19
  assert_response :ok
20
- assert_select "p", "Hello"
20
+ assert_select "p", "Привет"
21
21
  end
22
22
 
23
23
  def test_direct
24
- @request.host = "ru.example.com"
24
+ @request.host = "en.example.com"
25
25
  get :world
26
26
  assert_response :ok
27
- assert_select "p", "Привет"
27
+ assert_select "p", "Hello"
28
28
  end
29
29
 
30
30
  def test_custom
@@ -43,13 +43,13 @@ class HelloControllerTest < ActionController::TestCase
43
43
  def test_other
44
44
  @request.host = "wtf.example.com"
45
45
  get :world
46
- assert_select "p", "Hello"
46
+ assert_select "p", "Привет"
47
47
  end
48
48
  end
49
49
 
50
50
  class HelloMailerTest < ActionController::TestCase
51
51
  def test
52
- mail = I18n.with_locale(:ru) { HelloMailer.world }
53
- assert_equal "http://ru.example.com/", mail.body.to_s.lines[3].chomp
52
+ mail = I18n.with_locale(:uk) { HelloMailer.world }
53
+ assert_equal "http://ua.example.com/", mail.body.to_s.lines[3].chomp
54
54
  end
55
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subdomain_locale
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta5
4
+ version: 1.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Semyon Perepelitsa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: 1.3.1
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.2.2
81
+ rubygems_version: 2.2.0
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Set I18n locale based on subdomain