Permalink
Browse files

Released v2.0.0

Divided code into modules (Rich-i18n and Rich-pluralization)
  • Loading branch information...
1 parent 1bf5a75 commit 2cfc181aa599adaa9899810e61913d6638634084 Paul Engel committed Jul 20, 2010
View
@@ -1,5 +1,9 @@
= E9s CHANGELOG
+== Version 2.0.0 (July 18, 2010)
+
+* Divided code into modules (Rich-i18n and Rich-pluralization)
+
== Version 1.1.1 (July 10, 2010)
* Completed XSS approach implementation for printing meta data including labels and seatholders (leaving out String interpolation though!)
View
@@ -1,17 +1,17 @@
h1. E9s
-Enrichments (e9s) for Ruby Internationalization (i18n)
+Enrichments (e9s) for internationalization (i18n) and localized pluralization
h2. Introduction
-E9s was created due to the need of simply implementing I18n within a Rails application. It enriches I18n, Formtastic, the String and Symbol classes to make life easier for the Rails developer. A list of E9s' features:
+E9s was created due to the need of simply implementing I18n within a Rails application. It enriches I18n, Formtastic, the String and Symbol classes to make life easier for the Rails developer. E9s is divided into modules (as gem and plugin): Rich-i18n and Rich-pluralization. A list of E9s' features:
h3. I18n
* @Localized pluralization@ - Translations only in singular form are sufficient enough as E9s can pluralize in foreign languages
* @Default values@ - Use the translation key (or a portion) as default value: @"continue".t@ returns @"continue"@ and @"text.Welcome_to_our_site".t@ returns @"Welcome to our site"@
-* @An easy interface@ - Just call the @t@ method on string and symbols to translate and @pl@ to pluralize
+* @An easy interface@ - Just call the @t@ method on string or symbols to translate and @pl@ to pluralize
* @Combine translations@ - Joining keys with spaces combines translations: @"More houses".t@ returns @"Meer huizen"@ in Dutch
h3. Formtastic
@@ -235,7 +235,7 @@ For support, remarks and requests please mail me at "paul.engel@holder.nl":mailt
h2. Credit
-This Rails plugin depends on:
+This Rails gem / plugin depends on:
i18n<br>
"http://github.com/svenfuchs/i18n":http://github.com/svenfuchs/i18n
View
@@ -6,13 +6,14 @@ begin
require "jeweler"
Jeweler::Tasks.new do |gemspec|
gemspec.name = "e9s"
- gemspec.summary = "Enrichments (e9s) for Ruby Internationalization (i18n)"
+ gemspec.summary = "Enrichments (e9s) for internationalization (i18n) and localized pluralization"
gemspec.description = "E9s was created due to the need of simply implementing i18n within a Rails application. It enriches I18n, Formtastic, the String and Symbol classes to make life easier for the Rails developer."
gemspec.email = "paul.engel@holder.nl"
gemspec.homepage = "http://github.com/archan937/e9s"
gemspec.author = "Paul Engel"
- gemspec.add_dependency "formtastic"
+ gemspec.add_dependency "rich_i18n"
+ gemspec.add_dependency "rich_pluralization"
end
Jeweler::GemcutterTasks.new
rescue LoadError
View
@@ -1 +1 @@
-1.1.1
+2.0.0
View
@@ -1,8 +1,18 @@
module E9s
extend self
+
+ MODULES = %w(i18n pluralization)
+
+ def require_modules
+ MODULES.each do |mod|
+ require "rich/#{mod}"
+ end
+ rescue LoadError => e
+ # Re-raise as RuntimeError because Mongrel would swallow LoadError.
+ raise e.to_s
+ end
+
end
-require "e9s/core"
-require "e9s/actionpack"
-require "e9s/engine"
+E9s.require_modules
View
@@ -1,4 +0,0 @@
-
-require File.join(File.dirname(__FILE__), "actionpack", "action_controller", "dispatcher.rb")
-require File.join(File.dirname(__FILE__), "actionpack", "action_view" , "base.rb" )
-require File.join(File.dirname(__FILE__), "actionpack", "action_view" , "sanitizor.rb" )
@@ -1,12 +0,0 @@
-
-unless defined?(E9s::CONTROLLER_HOOKED)
-
- ActionController::Dispatcher.to_prepare :e9s_formtastic do
- if defined? Formtastic::SemanticFormBuilder
- Formtastic::SemanticFormBuilder.send :include, E9s::Formtastic unless Formtastic::SemanticFormBuilder.included_modules.include? E9s::Formtastic
- end
- end
-
- E9s::CONTROLLER_HOOKED = true
-
-end
@@ -1,13 +0,0 @@
-
-module ActionView
- class Base
-
- def render_with_e9s(*args, &block)
- (html = render_without_e9s(*args, &block)).include?("<i18n ") ?
- ::E9s::Actionpack::ActionView::Sanitizor.sanitize_html(html) :
- html
- end
- alias_method_chain :render, :e9s
-
- end
-end
@@ -1,59 +0,0 @@
-
-module E9s
- module Actionpack
- module ActionView
- module Sanitizor
- extend self
-
- require "hpricot"
-
- def sanitize_html(html)
- return html unless (html || "").include?("<i18n ")
-
- doc = Hpricot html
-
- (doc/"head i18n").each do |i18n|
- i18n.swap i18n.inner_html
- end
-
- (doc/"i18n").each do |i18n|
- elem = Hpricot::Elem.new "span", i18n.raw_attributes.merge({:class => "i18n"})
- elem.inner_html = i18n.inner_html
- i18n.swap elem.to_html
- end
-
- (doc/"input").each do |input|
- sanitize_input(input)
- end
-
- (doc/"textarea").each do |input|
- sanitize_input(input)
- end
-
- doc.to_html
- rescue
- html.gsub(/(\<i18n[^\>]+\>)|(\<\/i18n\>)/, "")
- end
-
- private
-
- def sanitize_input(input)
- %w(value seatholder).each do |input_attr|
- next unless input.attributes[input_attr].include?("<i18n ")
-
- i18n = Hpricot(input.attributes[input_attr]).children.first
- i18n.raw_attributes.each do |key, value|
- input.attributes[key] = value
- end
-
- input.attributes[input_attr] = i18n.inner_html
- input.attributes["class"] = ["i18n", input.attributes["class"]].uniq.join(" ").strip
- end
-
- input
- end
-
- end
- end
- end
-end
View
@@ -1,8 +0,0 @@
-
-(required_files = %w(object string enriched_string)).each do |file|
- require "e9s/core/#{file}"
-end
-
-Dir[File.join(File.dirname(__FILE__), "core", "*.rb")].each do |file|
- require file unless required_files.include?(File.basename file, ".rb")
-end
View
@@ -1,6 +0,0 @@
-
-require "e9s/core/array/merging"
-
-class Array
- include E9s::Core::Array::Merging
-end
@@ -1,27 +0,0 @@
-
-module E9s
- module Core
- module Array
- module Merging
-
- def self.included(base)
- base.class_eval do
- alias_method_chain :join, :e9s
- end
- end
-
- def join_with_e9s(sep = "")
- if size == 1 && first.is_a?(EnrichedString)
- first
- else
- merged_strings = dup
- result = join_without_e9s(sep)
- result.merged_strings = merged_strings
- result
- end
- end
-
- end
- end
- end
-end
@@ -1,28 +0,0 @@
-
-module E9s
- module Core
- class EnrichedString < ::String
-
- attr_accessor :meta_data
-
- def initialize(s = "", meta_data = nil)
- super s
- @meta_data = meta_data || (s.meta_data.dup unless (s.meta_data.nil? rescue true)) || {}
- end
-
- def initialize_copy_with_e9s(s)
- result = super(s)
- result.meta_data = self.meta_data.dup
- end
-
- def to_es
- @meta_data.empty? || !!::E9s::Engine.taggify_restriction || (send(::E9s::Engine.taggify_restriction) rescue false) ?
- to_s :
- "<i18n #{@meta_data.collect{|k, v| "data-#{k}=#{v.inspect}"}.join(" ")}>#{to_s}</i18n>"
- end
-
- end
- end
-end
-
-EnrichedString = E9s::Core::EnrichedString
View
@@ -1,6 +0,0 @@
-
-require "e9s/core/erb/output"
-
-class ERB::Compiler::Buffer
- include E9s::Core::ERB::Output
-end
View
@@ -1,20 +0,0 @@
-
-module E9s
- module Core
- module ERB
- module Output
-
- def self.included(base)
- base.class_eval do
- alias_method_chain :push, :e9s
- end
- end
-
- def push_with_e9s(cmd)
- push_without_e9s cmd.match(/^#{@compiler.insert_cmd}\(\(.*\)\.to_s\)$/) ? cmd.gsub(/to_s\)$/, "to_output)") : cmd
- end
-
- end
- end
- end
-end
View
@@ -1,6 +0,0 @@
-
-require "e9s/core/object/output"
-
-class Object
- include E9s::Core::Object::Output
-end
@@ -1,18 +0,0 @@
-
-module E9s
- module Core
- module Object
- module Output
-
- def to_output
- to_es
- end
-
- def to_es
- to_s
- end
-
- end
- end
- end
-end
View
@@ -1,10 +0,0 @@
-
-require "e9s/core/string/inflections"
-require "e9s/core/string/internationalization"
-require "e9s/core/string/enrichments"
-
-class String
- include E9s::Core::String::Inflections
- include E9s::Core::String::Internationalization
- include E9s::Core::String::Enrichments
-end
@@ -1,64 +0,0 @@
-
-module E9s
- module Core
- module String
- module Enrichments
-
- # TODO: override String interpolation (e.g. "foo #{"bar".t}")
-
- def self.included(base)
- base.class_eval do
- alias_method :add_without_e9s, :+
- alias_method :+, :add_with_e9s
- alias_method_chain :concat, :e9s
- undef_method :<<
- alias_method :<<, :concat_with_e9s
-
- alias_method_chain :initialize_copy, :e9s
- attr_accessor :merged_strings
- end
- end
-
- def initialize_copy_with_e9s(s)
- result = initialize_copy_without_e9s(s)
- result.merged_strings = self.merged_strings.try :dup
- end
-
- def add_with_e9s(other)
- strings, result = self.merged_strings.try(:dup) || [], add_without_e9s(other)
-
- if (result.merged_strings = strings).empty?
- result.merged_strings << self.dup
- end
- unless other.empty?
- result.merged_strings << other
- end
-
- result
- end
-
- def concat_with_e9s(other_or_fixnum)
- string, result = self.dup, concat_without_e9s(other_or_fixnum)
-
- if (result.merged_strings ||= []).empty? and !string.empty?
- result.merged_strings << string
- end
- result.merged_strings << other_or_fixnum.dup unless other_or_fixnum.empty?
-
- result
- end
-
- def enriched_string?
- is_a?(EnrichedString) or (merged_strings || []).any?(&:enriched_string?)
- end
-
- def to_output
- merged_strings.blank? ?
- to_es :
- merged_strings.collect(&:to_output).join
- end
-
- end
- end
- end
-end
Oops, something went wrong.

0 comments on commit 2cfc181

Please sign in to comment.