Permalink
Browse files

Added module specific localizations

  • Loading branch information...
1 parent 2cb3c73 commit df7a1a44715c39ecd8b43d87d92e65b674b70268 @lackac lackac committed Feb 6, 2009
Showing with 33 additions and 3 deletions.
  1. +2 −0 README.md
  2. +6 −3 app_lego.rb
  3. +11 −0 locale.rb
  4. +14 −0 locales/hu.auth.yml
View
@@ -43,6 +43,8 @@ The **CouchDB** module installs the [CouchRest](http://github.com/jchris/couchre
The **locale** module will download localization files from Sven Fuchs' [rails-i18n](http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) repository. The generator will ask for the list of the localizations the user wants, but it can be given through the `LOCALES` environment variable too. The list is comma separated, and where no extension is given `.yml` is assumed. The first locale in the list will be used as the default locale. Example:
$ LOCALES='hu,de,nl.rb' LEGOS='locale' rails -m http://github.com/lackac/app_lego/raw/master/app_lego.rb my_app
+
+The locale module also checks for module specific localizations in `locales/` under the same path App LEGO was called from.
The **misc** module inserts miscellaneous files into the application. These include a basic `application_controller.rb`, some helpers, a basic layout with flashes taken care of and some initializers.
View
@@ -1,12 +1,15 @@
# environment options
@lego_options = ENV['LEGOS'] ? ENV['LEGOS'].downcase.split(/[,\s]+/) : false
+@used_legos = []
def use_lego?(lego, question)
- if @lego_options
+ use = if @lego_options
@lego_options.include?(lego)
else
yes?(question)
end
+ @used_legos << lego if use
+ use
end
# braid helpers
@@ -42,7 +45,7 @@ def plugin(name, options)
if @lego_options or yes?("Do you want to play LEGO?")
all_yes = @lego_options ? false : yes?("Install everything without question?")
- base_path = if template =~ %r{^(/|\w+://)}
+ @base_path = if template =~ %r{^(/|\w+://)}
File.dirname(template)
else
log '', "You used the app generator with a relative template path."
@@ -51,7 +54,7 @@ def plugin(name, options)
modules.each do |modul, question|
if all_yes or use_lego?(modul, question)
- tmpl = "#{base_path}/#{modul}.rb"
+ tmpl = "#{@base_path}/#{modul}.rb"
log "applying", "template: #{tmpl}"
load_template(tmpl)
log "applied", tmpl
View
@@ -6,6 +6,17 @@
open("http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/#{locale}").read
end
+if @base_path
+ log '', 'Trying to download module specific localizations...'
+ @used_legos.each do |lego|
+ locales.each do |locale|
+ fn = "#{locale.split(".").first}.#{lego}.yml"
+ content = open("#{@base_path}/locales/#{fn}").read rescue nil
+ file "config/locales/#{fn}", content if content
+ end
+ end
+end
+
gsub_file "config/environment.rb",
/(#\s*)?config.i18n.default_locale.*$/,
"config.i18n.default_locale = '#{locales.first.gsub(/\.(yml|rb)$/, '')}'"
View
@@ -0,0 +1,14 @@
+hu:
+ authlogic:
+ error_messages:
+ login_blank: "nem lehet üres"
+ login_not_found: "nem található"
+ login_invalid: "csak betűket, számokat, szóközöket és a .-_@ karaktereket tartalmazhatja"
+ email_invalid: "email címnek kell kinéznie"
+ password_blank: "nem lehet üres"
+ password_invalid: "helytelen"
+ not_active: "A hozzáférésed még nincs aktiválva"
+ not_confirmed: "A hozzáférésed még nincs megerősítve"
+ not_approved: "A hozzáférésed még nincs jóváhagyva"
+ blank_record: "Nem jelentkezhetsz be üres adatokkal"
+ new_record: "Nem jelentkezhetsz be még nem mentett adatokkal"

0 comments on commit df7a1a4

Please sign in to comment.