padrino/padrino-contrib — pull request #18 by hongliang-goudou (2013-06-27 08:47:31+00:00)
Title: auto_locale wasn't compatible with asset paths

After register Padrino::Contrib::AutoLocale, every url is re-routed to '/:lang/...'. If developers put js/css/image files under public/ folder, it's ok. But if the files are served by asset pipeline gems, for example, sinatra-assetpack, the re-routed url will break down the asset serving system because there's a explicit not_found calling for invalid urls. So I added an exclusive path config. If the request url begins with the exclusive path, it doesn't call not_found. Problem sovled.

For example, the sinatra-assetpack would output something like this:
```html

```
This triggers a request, which url is "/js/application.12345.js". And of course it's not "/:lang/..." style. So auto_locale will call not_found and return http status 404. To solve the problem, add '/js' to the exclusive path:
```ruby
set :locale_exclusive_paths ['/js', '/css', '/img']
```
And now auto_locale won't call not_found any more. The file content will be well served by sinatra-assetpack.

If developers have already configured sinatra-assetpack, for example:
```ruby
serve '/js', from: 'js'
serve '/css', from: 'css'
serve '/img', from: 'img'
```
Then "set :locale_exclusive_paths ['/js', '/css', '/img']" is not required. The auto_locale will determine settings.assets configuration automatically. Everything should work and developers won't notice what's going on inside the auto_locale.