Port i18n to new sitemap api
This commit is contained in:
parent
2afbb40925
commit
d08624dfe3
|
@ -1,2 +1 @@
|
|||
* Finish i18n integration and documentation
|
||||
* Fix asset_hash ext with new sitemap
|
121
middleman-core/features/i18n_builder.feature
Normal file
121
middleman-core/features/i18n_builder.feature
Normal file
|
@ -0,0 +1,121 @@
|
|||
Feature: i18n Builder
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: Running localize with the default config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize
|
||||
"""
|
||||
Given a successfully built app at "i18n-test-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
| es/index.html |
|
||||
| es/hola.html |
|
||||
Then the following files should not exist:
|
||||
| en/index.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
And the file "hello.html" should contain "Hello World"
|
||||
And the file "es/index.html" should contain "Como Esta?"
|
||||
And the file "es/hola.html" should contain "Hola World"
|
||||
|
||||
Scenario: Running localize with the alt path config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :path => "/lang_:locale/"
|
||||
"""
|
||||
Given a successfully built app at "i18n-test-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
| lang_es/index.html |
|
||||
| lang_es/hola.html |
|
||||
Then the following files should not exist:
|
||||
| lang_en/index.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
And the file "hello.html" should contain "Hello World"
|
||||
And the file "lang_es/index.html" should contain "Como Esta?"
|
||||
And the file "lang_es/hola.html" should contain "Hola World"
|
||||
|
||||
Scenario: Running localize with the alt root config
|
||||
Given a fixture app "i18n-alt-root-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :templates_dir => "lang_data"
|
||||
"""
|
||||
Given a successfully built app at "i18n-alt-root-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
| es/index.html |
|
||||
| es/hola.html |
|
||||
Then the following files should not exist:
|
||||
| en/index.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
And the file "hello.html" should contain "Hello World"
|
||||
And the file "es/index.html" should contain "Como Esta?"
|
||||
And the file "es/hola.html" should contain "Hola World"
|
||||
|
||||
Scenario: Running localize with the lang map config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :lang_map => { :en => :english, :es => :spanish }
|
||||
"""
|
||||
Given a successfully built app at "i18n-test-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
| spanish/index.html |
|
||||
| spanish/hola.html |
|
||||
Then the following files should not exist:
|
||||
| english/index.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
And the file "hello.html" should contain "Hello World"
|
||||
And the file "spanish/index.html" should contain "Como Esta?"
|
||||
And the file "spanish/hola.html" should contain "Hola World"
|
||||
|
||||
Scenario: Running localize with the no mount config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :mount_at_root => false
|
||||
"""
|
||||
Given a successfully built app at "i18n-test-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| en/index.html |
|
||||
| en/hello.html |
|
||||
| es/index.html |
|
||||
| es/hola.html |
|
||||
Then the following files should not exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
And the file "en/index.html" should contain "Howdy"
|
||||
And the file "en/hello.html" should contain "Hello World"
|
||||
And the file "es/index.html" should contain "Como Esta?"
|
||||
And the file "es/hola.html" should contain "Hola World"
|
||||
|
||||
Scenario: Running localize with the subset config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :langs => [:en]
|
||||
"""
|
||||
Given a successfully built app at "i18n-test-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
| hello.html |
|
||||
Then the following files should not exist:
|
||||
| en/index.html |
|
||||
| es/index.html |
|
||||
| es/hola.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
And the file "hello.html" should contain "Hello World"
|
|
@ -1,36 +0,0 @@
|
|||
Feature: Builder Alt Path
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a successfully built app at "alt-path-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| index.html |
|
||||
And the file "index.html" should contain "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a successfully built app at "alt-path-app"
|
||||
When I cd to "build"
|
||||
Then the following files should not exist:
|
||||
| lang_en/index.html |
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a successfully built app at "alt-path-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| hello.html |
|
||||
And the file "hello.html" should contain "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a successfully built app at "alt-path-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| lang_es/index.html |
|
||||
And the file "lang_es/index.html" should contain "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a successfully built app at "alt-path-app"
|
||||
When I cd to "build"
|
||||
Then the following files should exist:
|
||||
| lang_es/hola.html |
|
||||
And the file "lang_es/hola.html" should contain "Hola World"
|
|
@ -1,22 +0,0 @@
|
|||
Feature: Builder Alt Root
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a built app at "alt-root-app"
|
||||
Then "index.html" should exist at "alt-root-app" and include "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "alt-root-app"
|
||||
Then "en/index.html" should not exist at "alt-root-app"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a built app at "alt-root-app"
|
||||
Then "hello.html" should exist at "alt-root-app" and include "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a built app at "alt-root-app"
|
||||
Then "es/index.html" should exist at "alt-root-app" and include "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a built app at "alt-root-app"
|
||||
Then "es/hola.html" should exist at "alt-root-app" and include "Hola World"
|
|
@ -1,22 +0,0 @@
|
|||
Feature: Builder Default
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "index.html" should exist at "i18n-test-app" and include "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "en/index.html" should not exist at "i18n-test-app"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "hello.html" should exist at "i18n-test-app" and include "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "es/index.html" should exist at "i18n-test-app" and include "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "es/hola.html" should exist at "i18n-test-app" and include "Hola World"
|
|
@ -1,22 +0,0 @@
|
|||
Feature: Builder Lang Map
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a built app at "name-map-app"
|
||||
Then "index.html" should exist at "name-map-app" and include "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "name-map-app"
|
||||
Then "english/index.html" should not exist at "name-map-app"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a built app at "name-map-app"
|
||||
Then "hello.html" should exist at "name-map-app" and include "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a built app at "name-map-app"
|
||||
Then "spanish/index.html" should exist at "name-map-app" and include "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a built app at "name-map-app"
|
||||
Then "spanish/hola.html" should exist at "name-map-app" and include "Hola World"
|
|
@ -1,26 +0,0 @@
|
|||
Feature: Builder No Mount
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a built app at "no-mount-app"
|
||||
Then "en/index.html" should exist at "no-mount-app" and include "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "no-mount-app"
|
||||
Then "index.html" should not exist at "no-mount-app"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a built app at "no-mount-app"
|
||||
Then "en/hello.html" should exist at "no-mount-app" and include "Hello World"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "no-mount-app"
|
||||
Then "hello.html" should not exist at "no-mount-app"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "es/index.html" should exist at "i18n-test-app" and include "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a built app at "i18n-test-app"
|
||||
Then "es/hola.html" should exist at "i18n-test-app" and include "Hola World"
|
|
@ -1,22 +0,0 @@
|
|||
Feature: Builder Subset
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given a built app at "subset-app"
|
||||
Then "index.html" should exist at "subset-app" and include "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given a built app at "subset-app"
|
||||
Then "en/index.html" should not exist at "subset-app"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given a built app at "subset-app"
|
||||
Then "hello.html" should exist at "subset-app" and include "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given a built app at "subset-app"
|
||||
Then "es/index.html" should not exist at "subset-app"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given a built app at "subset-app"
|
||||
Then "es/hola.html" should not exist at "subset-app"
|
113
middleman-core/features/i18n_preview.feature
Normal file
113
middleman-core/features/i18n_preview.feature
Normal file
|
@ -0,0 +1,113 @@
|
|||
Feature: i18n Preview
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: Running localize with the default config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize
|
||||
"""
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
||||
|
||||
Scenario: Running localize with the alt path config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :path => "/lang_:locale/"
|
||||
"""
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/lang_en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/lang_es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
When I go to "/lang_es/hola.html"
|
||||
Then I should see "Hola World"
|
||||
|
||||
|
||||
Scenario: Running localize with the alt root config
|
||||
Given a fixture app "i18n-alt-root-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :templates_dir => "lang_data"
|
||||
"""
|
||||
Given the Server is running at "i18n-alt-root-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
||||
|
||||
Scenario: Running localize with the lang map config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :lang_map => { :en => :english, :es => :spanish }
|
||||
"""
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/english/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/spanish/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
When I go to "/spanish/hola.html"
|
||||
Then I should see "Hola World"
|
||||
|
||||
Scenario: Running localize with the no mount config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :mount_at_root => false
|
||||
"""
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/en/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
||||
|
||||
Scenario: Running localize with the subset config
|
||||
Given a fixture app "i18n-test-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
localize :langs => [:en]
|
||||
"""
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "File Not Found"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "File Not Found"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview Alt Path
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/lang_en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/lang_es/"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/lang_es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "alt-path-app"
|
||||
When I go to "/lang_es/hola.html"
|
||||
Then I should see "Hola World"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview Alt Root
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/es/"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "alt-root-app"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview Default
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/es/"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "i18n-test-app"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview Lang Map
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/english/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/spanish/"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/spanish/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "name-map-app"
|
||||
When I go to "/spanish/hola.html"
|
||||
Then I should see "Hola World"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview No Mount
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/en/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/en/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/es/"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "Como Esta?"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "no-mount-app"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "Hola World"
|
|
@ -1,37 +0,0 @@
|
|||
Feature: Preview Subset
|
||||
In order to preview localized html
|
||||
|
||||
Scenario: EN should be at root
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN should be at root 2
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "Howdy"
|
||||
|
||||
Scenario: EN mounted at root should not be in directory
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/en/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized EN
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Hello World"
|
||||
|
||||
Scenario: ES should be under namespace
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/es/"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: ES should be under namespace 2
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/es/index.html"
|
||||
Then I should see "File Not Found"
|
||||
|
||||
Scenario: Paths can be localized ES
|
||||
Given the Server is running at "subset-app"
|
||||
When I go to "/es/hola.html"
|
||||
Then I should see "File Not Found"
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize :path => "/lang_:locale/"
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize :templates_dir => "lang_data"
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
en:
|
||||
greetings: "Howdy"
|
||||
hi: "Hello"
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
es:
|
||||
paths:
|
||||
hello: "hola"
|
||||
|
||||
greetings: "Como Esta?"
|
||||
hi: "Hola"
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:hi) %> World
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:greetings) %>
|
|
@ -1 +0,0 @@
|
|||
<%= yield %>
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize :lang_map => { :en => :english, :es => :spanish }
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
en:
|
||||
greetings: "Howdy"
|
||||
hi: "Hello"
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
es:
|
||||
paths:
|
||||
hello: "hola"
|
||||
|
||||
greetings: "Como Esta?"
|
||||
hi: "Hola"
|
|
@ -1 +0,0 @@
|
|||
<%= yield %>
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:hi) %> World
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:greetings) %>
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize :mount_at_root => false
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
en:
|
||||
greetings: "Howdy"
|
||||
hi: "Hello"
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
es:
|
||||
paths:
|
||||
hello: "hola"
|
||||
|
||||
greetings: "Como Esta?"
|
||||
hi: "Hola"
|
|
@ -1 +0,0 @@
|
|||
<%= yield %>
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:hi) %> World
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:greetings) %>
|
|
@ -1,2 +0,0 @@
|
|||
activate :i18n
|
||||
localize :langs => [:en]
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
en:
|
||||
greetings: "Howdy"
|
||||
hi: "Hello"
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
es:
|
||||
paths:
|
||||
hello: "hola"
|
||||
|
||||
greetings: "Como Esta?"
|
||||
hi: "Hola"
|
|
@ -1 +0,0 @@
|
|||
<%= yield %>
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:hi) %> World
|
|
@ -1 +0,0 @@
|
|||
<%= I18n.t(:greetings) %>
|
|
@ -10,9 +10,17 @@ module Middleman::CoreExtensions::I18n
|
|||
|
||||
app.send :include, InstanceMethods
|
||||
|
||||
# Needed for helpers as well
|
||||
app.after_configuration do
|
||||
::I18n.load_path += Dir[File.join(root, locales_dir, "*.yml")]
|
||||
end
|
||||
|
||||
app.ready do
|
||||
sitemap.register_resource_list_manipulator(
|
||||
:i18n,
|
||||
i18n
|
||||
)
|
||||
end
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
@ -36,9 +44,9 @@ module Middleman::CoreExtensions::I18n
|
|||
end
|
||||
|
||||
# Don't output localizable files
|
||||
ignore File.join(@templates_dir, "**/*")
|
||||
@app.ignore File.join(@templates_dir, "**")
|
||||
|
||||
sitemap.provides_metadata_for_path do |url|
|
||||
@app.sitemap.provides_metadata_for_path do |url|
|
||||
if d = get_localization_data(url)
|
||||
lang, page_id = d
|
||||
instance_vars = Proc.new {
|
||||
|
@ -61,33 +69,55 @@ module Middleman::CoreExtensions::I18n
|
|||
end
|
||||
end
|
||||
|
||||
def get_localization_data(url)
|
||||
if @mount_at_root
|
||||
else
|
||||
end
|
||||
def get_localization_data(path)
|
||||
@_localization_data ||= {}
|
||||
@_localization_data[path]
|
||||
end
|
||||
|
||||
# def paths_for_file(file)
|
||||
# url = @app.sitemap.source_map.index(file)
|
||||
# page_id = File.basename(url, File.extname(url))
|
||||
#
|
||||
# langs.map do |lang|
|
||||
# ::I18n.locale = lang
|
||||
#
|
||||
# # Build lang path
|
||||
# if @mount_at_root == lang
|
||||
# prefix = "/"
|
||||
# else
|
||||
# replacement = @lang_map.has_key?(lang) ? @lang_map[lang] : lang
|
||||
# prefix = @path.sub(":locale", replacement.to_s)
|
||||
# end
|
||||
#
|
||||
# localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id)
|
||||
#
|
||||
# path = File.join(prefix, url.sub(page_id, localized_page_id))
|
||||
# [lang, path, localized_page_id]
|
||||
# end
|
||||
# end
|
||||
# Update the main sitemap resource list
|
||||
# @return [void]
|
||||
def manipulate_resource_list(resources)
|
||||
@_localization_data = {}
|
||||
|
||||
new_resources = []
|
||||
|
||||
resources.each do |resource|
|
||||
next unless File.fnmatch(File.join(@templates_dir, "**"), resource.path)
|
||||
|
||||
page_id = File.basename(resource.path, File.extname(resource.path))
|
||||
|
||||
langs.map do |lang|
|
||||
::I18n.locale = lang
|
||||
|
||||
localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id)
|
||||
path = resource.path.sub(@templates_dir, "")
|
||||
|
||||
# Build lang path
|
||||
if @mount_at_root == lang
|
||||
prefix = "/"
|
||||
else
|
||||
replacement = @lang_map.has_key?(lang) ? @lang_map[lang] : lang
|
||||
prefix = @path.sub(":locale", replacement.to_s)
|
||||
end
|
||||
|
||||
path = ::Middleman::Util.normalize_path(
|
||||
File.join(prefix, path.sub(page_id, localized_page_id))
|
||||
)
|
||||
|
||||
@_localization_data[path] = [lang, path, localized_page_id]
|
||||
|
||||
p = ::Middleman::Sitemap::Resource.new(
|
||||
@app.sitemap,
|
||||
path
|
||||
)
|
||||
p.proxy_to(resource.path)
|
||||
|
||||
new_resources << p
|
||||
end
|
||||
end
|
||||
|
||||
resources + new_resources
|
||||
end
|
||||
end
|
||||
|
||||
# Frontmatter class methods
|
||||
|
@ -95,7 +125,7 @@ module Middleman::CoreExtensions::I18n
|
|||
|
||||
# Initialize the i18n
|
||||
def i18n
|
||||
@i18n ||= Localizer.new(self)
|
||||
@_i18n ||= Localizer.new(self)
|
||||
end
|
||||
|
||||
# Main i18n API
|
||||
|
|
Loading…
Reference in a new issue