Permalink
Browse files

- and more readme

  • Loading branch information...
1 parent 7329ad7 commit ee7cf440a5204752bb09e7598eaaab436a9a8c14 PerfectLine committed Apr 30, 2009
Showing with 33 additions and 40 deletions.
  1. +31 −38 README.rdoc → README.markdown
  2. +1 −1 Rakefile
  3. +1 −1 install.rb
@@ -1,70 +1,63 @@
-=== LocaleRouting
+# LocaleRouting
LocaleRouting makes parsing I18N locale from an url parameter seamless.
-It taps into the route recognition and generation methods and checks
-or adds the locale when nessecary.
+It taps into the route recognition and generation methods and checks or adds the locale when nessecary.
The plugin loads its available locales from Rails default I18N class.
-For every request, it checks if the firs 2 characters of the parameters part in the
-URL match any of the locale definitions exposed by I18n.available_locales.
-IF a locale string is found, the application I18n.locale is changed and the locale is passed
-via params[:locale].
+For every request, it checks if the firs 2 characters of the parameters part in the URL match any of the locale definitions exposed by I18n.available_locales.
+IF a locale string is found, the application I18n.locale is changed and the locale is passed via params[:locale].
-Access to mapped URLs is wrapped also, the current I18n.locale is always
-prepended to the generated URLs parameters. Additionally you can pass a
-{:locale => "en} option to your link helpers, which will inject the given
-locale into the output URL. This parameter defaults to I18n.locale.
+Access to mapped URLs is wrapped also, the current I18n.locale is always prepended to the generated URLs parameters.
+Additionally you can pass a {:locale => "en} option to your link helpers, which will inject the given locale into the output URL.
+This parameter defaults to I18n.locale.
No routes have to be changed to use this functionality.
-=== Configuration
+# Configuration
-To enable or disable the locale routing
-Perfectline::LocaleRouting.enabled = true/false # defaults to true
+To enable or disable the locale routing set Perfectline::LocaleRouting.enabled = true/false # defaults to true
+To specifiy which part of the URL should be matched for the locale identifier, set Perfectline::LocaleRouting.match_from = option
-To specifiy which part of the URL should be matched for the locale identifier
-Perfectline::LocaleRouting.match_from = option
+## Available options for match_from are:
+* :params
+ Searches for a 2 letter locale string in the parameters, specifically in the first query stirng token.
+ Found token is matched against I18n.available_locales and if no such locale exists, it will fall back to the default locale.
+ Example: www.myhost.com/en/foo/bar
-Available options for match_from are:
-* :params
- Searches for a 2 letter locale string in the parameters, specifically in the first query stirng token.
- Found token is matched against I18n.available_locales and if no such locale exists, it will fall back to the default locale.
- Example: www.myhost.com/en/foo/bar
-
- * Example:
+ Example:
www.myapp.com resolves to root controller with the default locale
www.myapp.com/en resolves to root controller with locale => "en"
www.myapp.com/foo/bar resolves to "foo" controller, "bar" action with default locale
www.myapp.com/fr/foo/bar resolves to "foo" controller, "bar" action with locale => "fr"
-* :host
- Searches for configured matches in the domain name. If a match is found, the configured locale is then checked against I18n.available_locales.
- If the configured locale does not exist in available locales, it will fall back to the default locale.
+* :host
+ Searches for configured matches in the domain name. If a match is found, the configured locale is then checked against I18n.available_locales.
+ If the configured locale does not exist in available locales, it will fall back to the default locale.
-Configuring host to locale mappings is done via Perfectline::LocaleRouting.create_mapping = hash.
-Hash key must be the hostname pattern to be matched and value is the locale string.
-Hostname patterns are like simplified regexp patterns with * wildcard support.
-Mappings matching is similar to route config - first match found is used, rest is ignored.
+ Configuring host to locale mappings is done via Perfectline::LocaleRouting.create_mapping = hash.
+ Hash key must be the hostname pattern to be matched and value is the locale string.
+ Hostname patterns are like simplified regexp patterns with * wildcard support.
+ Mappings matching is similar to route config - first match found is used, rest is ignored.
-Example:
- Perfectline::LocaleRouting.create_mapping({
+ Example:
+ Perfectline::LocaleRouting.create_mapping({
"en.dev.*" => "en", # matches en.dev.yoursite.com and en.dev.mysite.co.uk
"*.dev.*" => "en", # matches foo.dev.yoursite.com and www.dev.yoursite.com but not en.dev.mysite.com as its defined AFTER that mapping
"en.*" => "en", # matches en.yoursite.com but not en.dev.yoursite.com or en.foo.dev.yoursite.com as its defined AFTER that mapping
"*.com" => "en", # matches anything with a .com TLD
- })
+ })
-=== Warning
+# Warning
This plugin has not been fully tested with all possible cases except perhaps the params locale matching.
As you can see there are no tests yet either, although they will be created as soon as possible.
So if you do run into issues or have any improvement ideas, feel free to contact the authors.
-=== Honorable mentions
+# Honorable mentions
This plugin is heavily inspired by the "routing-filter" plugin by Sven Fuchs.
-=== Authors:
+# Authors:
Tanel Suurhans - tanel.suurhans__at__perfectline__d0t__ee
Tarmo Lehtpuu - tarmo.lehtpuu__at__perfectline__d0t_ee
-== License
-Copyright 2009 by PerfectLine LLC (www.perfectline.co.uk) and is released under the MIT license.
+# License
+Copyright 2009 by PerfectLine LLC (www.perfectline.co.uk) and is released under the MIT license.
View
@@ -18,6 +18,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'LocaleRouting'
rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('README.markdown')
rdoc.rdoc_files.include('lib/**/*.rb')
end
View
@@ -1,2 +1,2 @@
# spit out README
-puts IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+puts IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))

0 comments on commit ee7cf44

Please sign in to comment.