Permalink
Browse files

Initial import.

  • Loading branch information...
1 parent 941d5b1 commit fe500ac1c3212eeb77d65036f94abb9fe97be1de Masao Mutoh committed Feb 27, 2009
Showing with 18,198 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +55 −0 COPYING
  3. +108 −0 Rakefile
  4. +33 −0 lib/gettext_rails.rb
  5. +100 −0 lib/gettext_rails/action_controller.rb
  6. +45 −0 lib/gettext_rails/action_mailer.rb
  7. +16 −0 lib/gettext_rails/action_view.rb
  8. +130 −0 lib/gettext_rails/action_view/active_record_helper.rb
  9. +48 −0 lib/gettext_rails/action_view/date_helper.rb
  10. +26 −0 lib/gettext_rails/action_view/form_builder.rb
  11. +22 −0 lib/gettext_rails/tools.rb
  12. +13 −0 lib/gettext_rails/version.rb
  13. +89 −0 po/bg/gettext_rails.po
  14. +98 −0 po/bs/gettext_rails.po
  15. +90 −0 po/ca/gettext_rails.po
  16. +102 −0 po/cs/gettext_rails.po
  17. +94 −0 po/de/gettext_rails.po
  18. +89 −0 po/el/gettext_rails.po
  19. +90 −0 po/eo/gettext_rails.po
  20. +90 −0 po/es/gettext_rails.po
  21. +90 −0 po/et/gettext_rails.po
  22. +94 −0 po/fr/gettext_rails.po
  23. +87 −0 po/gettext_rails.pot
  24. +99 −0 po/hr/gettext_rails.po
  25. +90 −0 po/hu/gettext_rails.po
  26. +89 −0 po/it/gettext_rails.po
  27. +90 −0 po/ja/gettext_rails.po
  28. +87 −0 po/ko/gettext_rails.po
  29. +95 −0 po/lv/gettext_rails.po
  30. +91 −0 po/nb/gettext_rails.po
  31. +91 −0 po/nl/gettext_rails.po
  32. +91 −0 po/pt_BR/gettext_rails.po
  33. +98 −0 po/ru/gettext_rails.po
  34. +98 −0 po/sr/gettext_rails.po
  35. +11 −0 po/test.rb
  36. +104 −0 po/ua/gettext_rails.po
  37. +90 −0 po/vi/gettext_rails.po
  38. +86 −0 po/zh/gettext_rails.po
  39. +86 −0 po/zh_TW/gettext_rails.po
  40. +79 −0 sample/README
  41. +10 −0 sample/Rakefile
  42. +37 −0 sample/app/controllers/application_controller.rb
  43. +97 −0 sample/app/controllers/articles_controller.rb
  44. +3 −0 sample/app/helpers/application_helper.rb
  45. +60 −0 sample/app/helpers/articles_helper.rb
  46. +16 −0 sample/app/models/article.rb
  47. +22 −0 sample/app/views/articles/edit.html.erb
  48. +18 −0 sample/app/views/articles/index.html.erb
  49. +20 −0 sample/app/views/articles/new.html.erb
  50. +7 −0 sample/app/views/articles/show.html.erb
  51. +27 −0 sample/app/views/layouts/articles.html.erb
  52. +109 −0 sample/config/boot.rb
  53. +22 −0 sample/config/database.yml
  54. +45 −0 sample/config/environment.rb
  55. +17 −0 sample/config/environments/development.rb
  56. +27 −0 sample/config/environments/production.rb
  57. +27 −0 sample/config/environments/test.rb
  58. +7 −0 sample/config/initializers/backtrace_silencers.rb
  59. +10 −0 sample/config/initializers/inflections.rb
  60. +5 −0 sample/config/initializers/mime_types.rb
  61. +19 −0 sample/config/initializers/new_rails_defaults.rb
  62. +15 −0 sample/config/initializers/session_store.rb
  63. +5 −0 sample/config/locales/en.yml
  64. +45 −0 sample/config/routes.rb
  65. +19 −0 sample/db/schema.rb
  66. +2 −0 sample/doc/README_FOR_APP
  67. +13 −0 sample/lib/tasks/gettext.rake
  68. +2,856 −0 sample/log/development.log
  69. +101 −0 sample/po/bg/blog.po
  70. +102 −0 sample/po/blog.pot
  71. +103 −0 sample/po/bs/blog.po
  72. +101 −0 sample/po/ca/blog.po
  73. +104 −0 sample/po/cs/blog.po
  74. +104 −0 sample/po/de/blog.po
  75. +102 −0 sample/po/el/blog.po
  76. +103 −0 sample/po/en/blog.po
  77. +102 −0 sample/po/eo/blog.po
  78. +21 −0 sample/po/eo/tmp.patch
  79. +101 −0 sample/po/es/blog.po
  80. +102 −0 sample/po/fr/blog.po
  81. +102 −0 sample/po/hr/blog.po
  82. +101 −0 sample/po/hu/blog.po
  83. +102 −0 sample/po/it/blog.po
  84. +101 −0 sample/po/ja/blog.po
  85. +102 −0 sample/po/ko/blog.po
  86. +103 −0 sample/po/lv/blog.po
  87. +102 −0 sample/po/nb/blog.po
  88. +102 −0 sample/po/nl/blog.po
  89. +102 −0 sample/po/pt_BR/blog.po
  90. +102 −0 sample/po/ru/blog.po
  91. +103 −0 sample/po/sr/blog.po
  92. +105 −0 sample/po/ua/blog.po
  93. +102 −0 sample/po/vi/blog.po
  94. +101 −0 sample/po/zh/blog.po
  95. +103 −0 sample/po/zh_TW/blog.po
  96. +30 −0 sample/public/404.html
  97. +30 −0 sample/public/422.html
  98. +33 −0 sample/public/500.html
  99. 0 sample/public/favicon.ico
  100. BIN sample/public/images/rails.png
  101. +275 −0 sample/public/index.html
  102. +2 −0 sample/public/javascripts/application.js
  103. +963 −0 sample/public/javascripts/controls.js
  104. +973 −0 sample/public/javascripts/dragdrop.js
  105. +1,128 −0 sample/public/javascripts/effects.js
  106. +4,320 −0 sample/public/javascripts/prototype.js
  107. +5 −0 sample/public/robots.txt
  108. +136 −0 sample/public/stylesheets/blog.css
  109. +54 −0 sample/public/stylesheets/scaffold.css
  110. +4 −0 sample/script/about
  111. +3 −0 sample/script/console
  112. +3 −0 sample/script/dbconsole
  113. +3 −0 sample/script/destroy
  114. +3 −0 sample/script/generate
  115. +3 −0 sample/script/performance/benchmarker
  116. +3 −0 sample/script/performance/profiler
  117. +3 −0 sample/script/plugin
  118. +3 −0 sample/script/runner
  119. +3 −0 sample/script/server
  120. +11 −0 sample/test/fixtures/articles.yml
  121. +45 −0 sample/test/functional/articles_controller_test.rb
  122. +9 −0 sample/test/performance/browsing_test.rb
  123. +38 −0 sample/test/test_helper.rb
  124. +8 −0 sample/test/unit/article_test.rb
  125. +4 −0 sample/test/unit/helpers/articles_helper_test.rb
  126. +17 −0 sample/vendor/plugins/lang_helper/README
  127. +17 −0 sample/vendor/plugins/lang_helper/Rakefile
  128. +21 −0 sample/vendor/plugins/lang_helper/init.rb
  129. +31 −0 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
  130. +27 −0 sample/vendor/plugins/lang_helper/po/bg/lang_helper.po
  131. +27 −0 sample/vendor/plugins/lang_helper/po/bs/lang_helper.po
  132. +27 −0 sample/vendor/plugins/lang_helper/po/ca/lang_helper.po
  133. +29 −0 sample/vendor/plugins/lang_helper/po/cs/lang_helper.po
  134. +29 −0 sample/vendor/plugins/lang_helper/po/de/lang_helper.po
  135. +27 −0 sample/vendor/plugins/lang_helper/po/el/lang_helper.po
  136. +28 −0 sample/vendor/plugins/lang_helper/po/eo/lang_helper.po
  137. +28 −0 sample/vendor/plugins/lang_helper/po/es/lang_helper.po
  138. +27 −0 sample/vendor/plugins/lang_helper/po/fr/lang_helper.po
  139. +27 −0 sample/vendor/plugins/lang_helper/po/hr/lang_helper.po
  140. +27 −0 sample/vendor/plugins/lang_helper/po/hu/lang_helper.po
  141. +27 −0 sample/vendor/plugins/lang_helper/po/it/lang_helper.po
  142. +28 −0 sample/vendor/plugins/lang_helper/po/ja/lang_helper.po
  143. +27 −0 sample/vendor/plugins/lang_helper/po/ko/lang_helper.po
  144. +28 −0 sample/vendor/plugins/lang_helper/po/lang_helper.pot
  145. +28 −0 sample/vendor/plugins/lang_helper/po/lv/lang_helper.po
  146. +29 −0 sample/vendor/plugins/lang_helper/po/nb/lang_helper.po
  147. +28 −0 sample/vendor/plugins/lang_helper/po/nl/lang_helper.po
  148. +27 −0 sample/vendor/plugins/lang_helper/po/pt_BR/lang_helper.po
  149. +25 −0 sample/vendor/plugins/lang_helper/po/ru/lang_helper.po
  150. +28 −0 sample/vendor/plugins/lang_helper/po/sr/lang_helper.po
  151. +30 −0 sample/vendor/plugins/lang_helper/po/ua/lang_helper.po
  152. +27 −0 sample/vendor/plugins/lang_helper/po/vi/lang_helper.po
  153. +27 −0 sample/vendor/plugins/lang_helper/po/zh/lang_helper.po
  154. +29 −0 sample/vendor/plugins/lang_helper/po/zh_TW/lang_helper.po
View
@@ -0,0 +1,3 @@
+pkg
+data
+sample/vendor/lang_helper/locale
View
@@ -0,0 +1,55 @@
+You can redistribute this program and/or modify it under either the terms of
+the LGPL (see the file LGPL), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or executable
+ form, provided that you do at least ONE of the following:
+
+ a) distribute the executables and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under these terms.
+
+ For the list of those files and their copying conditions, see the
+ file LEGAL.
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
View
@@ -0,0 +1,108 @@
+#
+# Rakefile for gettext_rails.
+#
+# Use setup.rb or gem for installation.
+# You don't need to use this file directly.
+#
+# Copyright(c) 2009 Masao Mutoh
+#
+# This program is licenced under the same licence as Ruby.
+#
+
+#make lib and paralel gettext checkout available
+$LOAD_PATH.unshift "./lib"
+gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
+$LOAD_PATH.unshift gettext_path
+
+require 'rubygems'
+require 'rake'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+
+gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
+$LOAD_PATH.unshift gettext_path
+
+require 'gettext_rails/version'
+
+PKG_VERSION = GetTextRails::VERSION
+
+task :default => [:makemo]
+
+############################################################
+# Manage po/mo files
+############################################################
+desc "Create *.mo from *.po"
+task :makemo do
+ $stderr.puts "Create active_record mo files."
+ require 'gettext/tools'
+ GetText.create_mofiles
+end
+
+desc "Update pot/po files to match new version."
+task :updatepo do
+ require 'gettext/tools'
+
+ GetText.update_pofiles("gettext_rails",
+ Dir.glob("lib/**/*.rb"),
+ "gettext_rails #{PKG_VERSION}")
+
+end
+
+############################################################
+# Package tasks
+############################################################
+
+desc "Create gem and tar.gz"
+spec = Gem::Specification.new do |s|
+ s.name = 'gettext_rails'
+ s.version = PKG_VERSION
+ s.summary = 'Localization support for Ruby on Rails(>=2.3) by Ruby-GetText-Package.'
+ s.author = 'Masao Mutoh'
+ s.email = 'mutoh@highway.ne.jp'
+ s.homepage = 'http://gettext.rubyforge.org/'
+ s.rubyforge_project = "gettext"
+ s.files = FileList['**/*'].to_a.select{|v| v !~ /pkg|git/}
+ s.require_path = 'lib'
+ s.has_rdoc = true
+ s.description = 'Localization support for Ruby on Rails(>=2.3) by Ruby-GetText-Package.'
+end
+
+Rake::PackageTask.new("gettext_rails", PKG_VERSION) do |o|
+ o.package_files = FileList['**/*'].to_a.select{|v| v !~ /pkg|git/}
+ o.need_tar_gz = true
+ o.need_zip = false
+end
+
+Rake::GemPackageTask.new(spec) do |p|
+ p.gem_spec = spec
+ p.need_tar_gz = false
+ p.need_zip = false
+end
+
+############################################################
+# Misc tasks
+############################################################
+
+Rake::RDocTask.new { |rdoc|
+ allison = `allison --path`.chop
+ rdoc.rdoc_dir = 'doc'
+ rdoc.title = "gettext_rails API Reference"
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README', 'ChangeLog')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+ rdoc.template = allison if allison.size > 0
+}
+
+desc "Publish the release files to RubyForge."
+task :release => [ :package ] do
+ require 'rubyforge'
+
+ rubyforge = RubyForge.new
+ rubyforge.login
+ rubyforge.add_release("gettext_rails", "gettext_rails",
+ "gettext_rails #{PKG_VERSION}",
+ "pkg/gettext_rails-#{PKG_VERSION}.gem",
+ "pkg/gettext_rails-#{PKG_VERSION}.tar.gz")
+end
+
View
@@ -0,0 +1,33 @@
+=begin
+ gettext_rails.rb- GetText for "Ruby on Rails"
+
+ Copyright (C) 2005-2009 Masao Mutoh
+
+ You may redistribute it and/or modify it under the same
+ license terms as Ruby.
+
+ Original: gettext/lib/rails.rb from Ruby-GetText-Package-1.93.0
+
+ $Id$
+=end
+
+require 'gettext_rails/action_controller.rb'
+require 'gettext_rails/action_view.rb'
+require 'gettext_rails/action_mailer.rb'
+require 'gettext_rails/version.rb'
+
+begin
+ Rails::Info.property("GetText version") do
+ GetText::VERSION
+ end
+ Rails::Info.property("GetText for Rails version") do
+ GetTextRails::VERSION
+ end
+rescue Exception
+ $stderr.puts "GetText's Rails::Info is not found." if $DEBUG
+end
+
+if ::RAILS_ENV == "development"
+ GetText::TextDomainManager.cached = false
+end
+
@@ -0,0 +1,100 @@
+=begin
+ gettext_rails/action_controller.rb - GetText for ActionController.
+
+ Copyright (C) 2005-2009 Masao Mutoh
+
+ You may redistribute it and/or modify it under the same
+ license terms as Ruby.
+
+ Original: gettext/lib/rails.rb from Ruby-GetText-Package-1.93.0
+
+ $Id$
+=end
+require 'gettext/cgi'
+require 'locale_rails'
+require 'action_controller'
+
+module ActionController #:nodoc:
+ class Base
+ include GetText
+
+ # Append a block which is called before initializing gettext on the each WWW request.
+ #
+ # (e.g.)
+ # class ApplicationController < ActionController::Base
+ # before_init_gettext{|controller|
+ # cookies = controller.cookies
+ # if (cookies["lang"].nil? or cookies["lang"].empty?)
+ # GetText.locale = "zh_CN"
+ # else
+ # GetText.locale = cookies["lang"]
+ # end
+ # }
+ # init_gettext "myapp"
+ # # ...
+ # end
+ alias :before_init_gettext :after_init_locale
+
+ # Append a block which is called after initializing gettext on the each WWW request.
+ #
+ # The GetText.locale is set the locale which bound to the textdomains
+ # when gettext is initialized.
+ #
+ # (e.g.)
+ # class ApplicationController < ActionController::Base
+ # after_init_gettext {|controller|
+ # L10nClass.new(GetText.locale)
+ # }
+ # init_gettext "foo"
+ # # ...
+ # end
+ alias :after_init_gettext :after_init_locale
+
+ # Bind a 'textdomain' to all of the controllers/views/models. Call this instead of GetText.bindtextdomain.
+ # * textdomain: the textdomain
+ # * options: options as a Hash.
+ # * :charset - the output charset. Default is "UTF-8"
+ # * :locale_path - the path to locale directory. Default is {RAILS_ROOT}/locale or {plugin root directory}/locale.
+ #
+ # locale is searched the order by params["lang"] > "lang" value of QUERY_STRING >
+ # "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value > Default locale(en).
+ # And the charset is set order by "the argument of bindtextdomain" > HTTP_ACCEPT_CHARSET > Default charset(UTF-8).
+ # Refer Ruby-Locale for more details.
+ #
+ # If you want to separate the textdomain each controllers, you need to call this function in the each controllers.
+ #
+ # app/controller/blog_controller.rb:
+ # class BlogController < ApplicationController
+ # init_gettext "blog"
+ # :
+ # end
+ def self.init_gettext(domainname, options = {})
+ opt = {:charset => "UTF-8"}.merge(options)
+
+ set_output_charset(opt[:charset])
+ locale_path = opt[:locale_path]
+ unless locale_path
+ cal = caller[0]
+ if cal =~ /app.controllers/
+ # Don't use RAILS_ROOT first, for RailsEngines.
+ locale_path = File.join(cal.split(/app.controllers/)[0] + "locale")
+ else
+ locale_path = File.join(RAILS_ROOT, "locale")
+ end
+ end
+
+ bindtextdomain(domainname, {:path => locale_path})
+
+ if defined? ActiveRecord::Base
+ bindtextdomain_to(ActiveRecord::Base, domainname)
+ bindtextdomain_to(ActiveRecord::Validations, domainname)
+ end
+ bindtextdomain_to(ActionView::Base, domainname) if defined? ActionView::Base
+ bindtextdomain_to(ApplicationHelper, domainname) if defined? ApplicationHelper
+ bindtextdomain_to(ActionMailer::Base, domainname) if defined? ActionMailer::Base
+ bindtextdomain_to(ActionView::Helpers, domainname) if defined? ActionView::Helpers
+ end
+
+ end
+
+end
@@ -0,0 +1,45 @@
+=begin
+ gettext_rails/action_mailer.rb - GetText for ActionMailer.
+
+ Copyright (C) 2005-2009 Masao Mutoh
+
+ You may redistribute it and/or modify it under the same
+ license terms as Ruby.
+
+ Original: gettext/lib/rails.rb from Ruby-GetText-Package-1.93.0
+
+ $Id$
+=end
+
+if defined? ActionMailer
+ module ActionMailer #:nodoc:
+ class Base #:nodoc:
+ include GetText
+
+ def base64(text, charset="iso-2022-jp", convert=true)
+ if convert
+ if charset == "iso-2022-jp"
+ text = NKF.nkf('-j -m0', text)
+ end
+ end
+ text = TMail::Base64.folding_encode(text)
+ "=?#{charset}?B?#{text}?="
+ end
+
+ def create_bang_with_gettext(*arg) #:nodoc:
+ create_without_gettext!(*arg)
+ if Locale.get.language == "ja"
+ require 'nkf'
+ @mail.subject = base64(@mail.subject)
+ part = @mail.parts.empty? ? @mail : @mail.parts.first
+ if part.content_type == 'text/plain'
+ part.charset = 'iso-2022-jp'
+ part.body = NKF.nkf('-j', part.body)
+ end
+ end
+ @mail
+ end
+ alias_method_chain :create!, :gettext
+ end
+ end
+end
@@ -0,0 +1,16 @@
+=begin
+ gettext_rails/action_view.rb- GetText for ActionView.
+
+ Copyright (C) 2009 Masao Mutoh
+
+ You may redistribute it and/or modify it under the same
+ license terms as Ruby.
+
+ Original: gettext/lib/rails.rb from Ruby-GetText-Package-1.93.0
+
+ $Id$
+=end
+
+#require 'gettext_rails/action_view/active_record_helper'
+require 'gettext_rails/action_view/date_helper'
+require 'gettext_rails/action_view/form_builder'
Oops, something went wrong.

0 comments on commit fe500ac

Please sign in to comment.