Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial release v1.0.0

  • Loading branch information...
commit 6240f64fa53b736f685dec46bf60801e1aad0c06 0 parents
Paul Engel authored
5 CHANGELOG
@@ -0,0 +1,5 @@
+= Rich-pluralization CHANGELOG
+
+== Version 1.0.0 (July 20, 2010)
+
+* Initial release (extracted Rich-pluralization from E9s)
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Paul Engel
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
143 README.textile
@@ -0,0 +1,143 @@
+
+h1. Rich-pluralization
+
+Enrichments (e9s) module for localized pluralization
+
+h2. Introduction
+
+Rich-pluralization is a module of E9s ("http://github.com/archan937/e9s":http://github.com/archan937/e9s) which provides localized pluralization in combination with i18n. Doing this enables you to only translate words in singular form as the module pluralizes the translation for you.
+
+h2. Installation
+
+h3. Using Rich-pluralization as gem
+
+Install the Rich-pluralization gem:
+
+<pre>
+ sudo gem install rich_pluralization
+</pre>
+
+Add rich_pluralization in environment.rb as a gem dependency:
+
+<pre>
+ config.gem "rich_pluralization"
+</pre>
+
+h3. Using Rich-pluralization as plugin
+
+Install the Rich-pluralization plugin:
+
+<pre>
+ ./script/plugin install git://github.com/archan937/rich_pluralization.git
+</pre>
+
+h2. Usage
+
+Just call the @pl@ method on string or symbols to pluralize.
+
+*Note*: @I18n.locale@ is @:nl@
+
+<pre>
+ >> "brief".pl
+ => "brieven"
+ >> "gebruiker".pl
+ => "gebruikers"
+ >> :museum.pl
+ => "musea"
+ >> "afspraak".pl
+ => "afspraken"
+</pre>
+
+h3. Adding pluralization rules / inflections
+
+Rich-pluralization inflections resembles the inflections of @ActiveSupport::Inflector@. Unfortunately, specifying inflections within @config/initializers/inflections.rb@ influences your Rails application and thus causes great problems.
+
+To specify pluralization rules for different locales. You have to use regular expressions and put them in @config/locales/language.yml@.
+
+*Note*: specified in @config/locales/nl.yml@
+
+<pre>
+---
+nl:
+
+ e9s:
+ singular:
+ - rule: en$
+ replacement: ""
+
+ plural:
+ - rule: ee$
+ replacement: eeën
+
+ - rule: heid$
+ replacement: heden
+
+ - rule: (c|m|n|t)us$
+ replacement: \1i
+
+ - rule: | abc, acme, acne, (a|ë|i|o|u|y)$
+ replacement: \1's
+ exceptions: (ai|eau|ei|li|lieu|ooi|ou|shampoo|spray|vlo)$
+
+ - rule: (blad|kind)$
+ replacement: \1eren
+ exceptions: (aanrecht|advertentie)blad
+
+ - rule: (e|em|el|er|erd|aar|aard|um|eur|foon|oor|ier|en|ie|eau|show|festival|é)$
+ replacement: \1s
+
+ - rule: | (a|e|o|u)\1([^aeiou])$
+ replacement: \1\2en
+
+ - rule: | (aï|alia)(s),
+ ([^aeiou][aeiou])([^aeiou])$
+ replacement: \1\2\2en
+ exceptions: dal, pad, slot, vat, weg,
+ (blad|dag|dak|engel|gat|weg)$
+
+ - rule: f$
+ replacement: ven
+
+ - rule: s$
+ replacement: zen
+
+ - rule: $
+ replacement: en
+
+ irregular:
+ gelid: gelederen
+
+ uncountable:
+ - geld
+ - informatie
+ - rijst
+</pre>
+
+For a complete example, please open "http://github.com/archan937/rich_pluralization/locales/nl.yml":http://github.com/archan937/rich_pluralization/locales/nl.yml which contains Dutch inflections.
+
+h2. Contact me
+
+For support, remarks and requests please mail me at "paul.engel@holder.nl":mailto:paul.engel@holder.nl.
+
+h2. Credit
+
+This Rails gem / plugin depends on:
+
+i18n<br>
+"http://github.com/svenfuchs/i18n":http://github.com/svenfuchs/i18n
+
+h2. ToDo's
+
+* Complete the Dutch inflections
+
+h2. License
+
+Copyright (c) 2010 Paul Engel, released under the MIT license
+
+"http://holder.nl":http://holder.nl - "http://codehero.es":http://codehero.es - "http://gettopup.com":http://gettopup.com - "http://twitter.com/archan937":http://twitter.com/archan937 - "paul.engel@holder.nl":mailto:paul.engel@holder.nl
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 Rakefile
@@ -0,0 +1,41 @@
+require "rake"
+require "rake/testtask"
+require "rake/rdoctask"
+
+begin
+ require "jeweler"
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "rich_pluralization"
+ gemspec.summary = "Enrichments (e9s) module for localized pluralization"
+ gemspec.description = "Rich-pluralization is a module of E9s (http://github.com/archan937/e9s) which provides localized pluralization in combination with i18n. Doing this enables you to only translate words in singular form as the module pluralizes the translation for you."
+ gemspec.email = "paul.engel@holder.nl"
+ gemspec.homepage = "http://github.com/archan937/rich_pluralization"
+ gemspec.author = "Paul Engel"
+
+ gemspec.add_dependency "i18n"
+ end
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+end
+
+desc "Default: run unit tests."
+task :default => :test
+
+desc "Test the rich_pluralization plugin."
+Rake::TestTask.new(:test) do |t|
+ t.libs << "lib"
+ t.libs << "test"
+ t.pattern = "test/**/*_test.rb"
+ t.verbose = true
+end
+
+desc "Generate documentation for the rich_pluralization plugin."
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = "rdoc"
+ rdoc.title = "Rich-pluralization"
+ rdoc.options << "--line-numbers" << "--inline-source"
+ rdoc.rdoc_files.include "README"
+ rdoc.rdoc_files.include "MIT-LICENSE"
+ rdoc.rdoc_files.include "lib/**/*.rb"
+end
1  VERSION
@@ -0,0 +1 @@
+1.0.0
1  init.rb
@@ -0,0 +1 @@
+require File.join(File.dirname(__FILE__), "rails", "init")
1  install.rb
@@ -0,0 +1 @@
+# Install hook code here
9 lib/rich/pluralization.rb
@@ -0,0 +1,9 @@
+
+module Rich
+ module Pluralization
+ extend self
+ end
+end
+
+require "rich/pluralization/core"
+require "rich/pluralization/engine"
4 lib/rich/pluralization/core.rb
@@ -0,0 +1,4 @@
+
+Dir[File.join(File.dirname(__FILE__), "core", "*.rb")].each do |file|
+ require file
+end
6 lib/rich/pluralization/core/string.rb
@@ -0,0 +1,6 @@
+
+require "rich/pluralization/core/string/inflections"
+
+class String
+ include Rich::Pluralization::Core::String::Inflections
+end
16 lib/rich/pluralization/core/string/inflections.rb
@@ -0,0 +1,16 @@
+
+module Rich
+ module Pluralization
+ module Core
+ module String
+ module Inflections
+
+ def pl(count = nil)
+ Rich::Pluralization::Inflector.pluralize self, count
+ end
+
+ end
+ end
+ end
+ end
+end
6 lib/rich/pluralization/core/symbol.rb
@@ -0,0 +1,6 @@
+
+require "rich/pluralization/core/symbol/inflections"
+
+class Symbol
+ include Rich::Pluralization::Core::Symbol::Inflections
+end
16 lib/rich/pluralization/core/symbol/inflections.rb
@@ -0,0 +1,16 @@
+
+module Rich
+ module Pluralization
+ module Core
+ module Symbol
+ module Inflections
+
+ def pl(count = nil)
+ to_s.pl count
+ end
+
+ end
+ end
+ end
+ end
+end
42 lib/rich/pluralization/engine.rb
@@ -0,0 +1,42 @@
+
+module Rich
+ module Pluralization
+ module Engine
+ extend self
+
+ def init(test_class = nil)
+ if test_class
+ test_locale = test_class.name.match(/(Rich\:\:Pluralization\:\:Test\:\:Locales\:\:)(\w+)/).captures[1].downcase.to_sym
+
+ I18n.load_path = [File.join("vendor", "plugins", "rich_pluralization", "locales", "#{test_locale}.yml")]
+ else
+ I18n.load_path += Dir[Rails.root.join("vendor", "plugins", "rich_pluralization", "locales", "*.yml")]
+ end
+
+ I18n.backend.reload!
+ Rich::Pluralization::Inflector.inflections.reset_attrs if test_class
+
+ initial_locale = I18n.locale
+
+ I18n.backend.available_locales.each do |locale|
+ I18n.locale = locale
+
+ Rich::Pluralization::Inflector.inflections locale do |inflections|
+ (I18n.t! "e9s" rescue []).each do |type, entries|
+ entries.each do |inflection|
+ inflections.send *[type, inflection].flatten
+ end
+ end
+ end
+ end
+
+ I18n.locale = initial_locale
+
+ test_locale
+ end
+
+ end
+ end
+end
+
+Rich::Pluralization::Engine.init
58 lib/rich/pluralization/inflector.rb
@@ -0,0 +1,58 @@
+
+module Rich
+ module Pluralization
+ module Inflector
+ extend self
+
+ def inflections(locale = nil)
+ Inflections.instance.locale = locale
+ if block_given?
+ yield Inflections.instance
+ else
+ Inflections.instance
+ end
+ end
+
+ def singularize(word)
+ inflect :singulars, word
+ end
+
+ def pluralize(word, count = nil)
+ count == 1 ? singularize(word) : inflect(:plurals, word)
+ end
+
+ private
+
+ [:singulars, :plurals, :irregulars, :uncountables].each do |type|
+ define_method type do
+ (Inflections.instance.send(type)[I18n.locale] || (type == :uncountables ? [] : {}))
+ end
+ end
+
+ def inflect(type, word)
+ return word if uncountable?(word) or irregular_counterpart?(type, word)
+
+ if irregular = irregulars[word.downcase]
+ return irregular.cp_case(word)
+ end
+
+ send(type).each do |inflection|
+ if result = inflection.inflect!(word)
+ return result.cp_case(word)
+ end
+ end
+
+ word
+ end
+
+ def uncountable?(word)
+ uncountables.include?(word.downcase)
+ end
+
+ def irregular_counterpart?(type, word)
+ irregulars.send({:singulars => :keys, :plurals => :values}[type]).include?(word.downcase)
+ end
+
+ end
+ end
+end
136 lib/rich/pluralization/inflector/inflections.rb
@@ -0,0 +1,136 @@
+
+module Rich
+ module Pluralization
+ module Inflector
+
+ class Inflections
+ include Singleton
+
+ attr_reader :singulars, :plurals, :irregulars, :uncountables
+ attr_writer :locale
+
+ def initialize
+ set_attrs
+ end
+
+ def set_attrs
+ %w(singulars plurals irregulars uncountables).each do |x|
+ instance_variable_set :"@#{x}", {}
+ end
+ @locale = I18n.default_locale
+ end
+ alias :reset_attrs :set_attrs
+
+ def singular(*args)
+ add_inflection :singulars, *args
+ end
+
+ def plural(*args)
+ add_inflection :plurals , *args
+ end
+
+ def irregular(*args)
+ locale, s, pl = extract_args(*args)
+ (@irregulars[locale] ||= {})[s.to_s] = pl
+ end
+
+ def uncountable(*args)
+ locale, words = extract_args(*args)
+ (@uncountables[locale] ||= []).concat [words].flatten
+ end
+
+ def dump
+ puts "SINGULARS : #{@singulars .inspect}"
+ puts "PLURAL : #{@plurals .inspect}"
+ puts "IRREGULARS : #{@irregulars .inspect}"
+ puts "UNCOUNTABLES: #{@uncountables.inspect}"
+ puts "LOCALE : #{@locale .inspect}"
+ end
+
+ private
+
+ def add_inflection(type, *args)
+ locale, values = extract_args(*args)
+ inflections = instance_variable_get(:"@#{type}")
+ inflection = Inflection.build values
+
+ (inflections[locale] ||= []).push inflection
+ end
+
+ def extract_args(*args)
+ locale = begin
+ if args.last.is_a?(Symbol)
+ args.pop
+ elsif args.last.is_a?(Hash)
+ args.delete(:locale)
+ end
+ end
+
+ args.unshift [locale, @locale].detect{|x| x.is_a?(Symbol)} || I18n.default_locale
+ end
+
+ Inflection = Struct.new(:rule, :replacement, :exceptions) do
+
+ def self.build(*args)
+ self.new *(args.first.is_a?(Hash) ? args.first.values_at(*%w(rule replacement exceptions)) : args)
+ end
+
+ def rule
+ self[:rule].downcase
+ end
+
+ def exceptions
+ (self[:exceptions] || "").downcase.split(",")
+ end
+
+ def exception?(word)
+ exceptions.any?{|e| match?(word, e)}
+ end
+
+ def match?(word, pattern)
+ w, p = word.downcase, parse_pattern(pattern)
+ p.is_a?(Regexp) ? !!w.match(p) : (w == p)
+ end
+
+ def inflect(word)
+ if exception?(word)
+ word
+ else
+ rule.split(",").collect do |x|
+ word.dup.gsub! parse_pattern(x, true), self[:replacement]
+ end.detect{|x| !x.nil?} || word
+ end
+ end
+
+ def inflect!(word)
+ (result = inflect(word)) == word ? nil : result
+ end
+
+ def inspect
+ to_hash.inspect
+ end
+
+ def to_hash
+ Hash[*members.zip(values).flatten]
+ end
+
+ private
+
+ def parse_pattern(s, force_regexp = false)
+ s.strip!
+ if force_regexp and not regexp?(s)
+ s = "^(#{s.strip})$"
+ end
+ regexp?(s) ? Regexp.new(s, Regexp::IGNORECASE) : s
+ end
+
+ def regexp?(s)
+ !!s.match(/[\^\$\(\)]/)
+ end
+
+ end
+ end
+
+ end
+ end
+end
148 locales/nl.yml
@@ -0,0 +1,148 @@
+---
+nl:
+
+ e9s:
+ singular:
+ - rule: en$
+ replacement: ""
+
+ plural:
+ - rule: cees$
+ replacement: cesen
+
+ - rule: chys$
+ replacement: chen
+
+ - rule: (c|m|n|t)us$
+ replacement: \1i
+ exceptions: | abortus, anus
+
+ - rule: (c|d|e|i|t|tr|v)um$
+ replacement: \1a
+ exceptions: (anthu|aqua)rium
+
+ - rule: ee$
+ replacement: eeën
+ exceptions: abonnee
+
+ - rule: eum$
+ replacement: ea
+
+ - rule: heid$
+ replacement: heden
+
+ - rule: dix$
+ replacement: dices
+
+ - rule: lid$
+ replacement: leden
+
+ - rule: (nuens)is$
+ replacement: \1es
+
+ - rule: stad$
+ replacement: steden
+
+ - rule: | abc, acme, acne, (a|ë|i|o|u|y)$
+ replacement: \1's
+ exceptions: (ai|eau|ei|li|lieu|ooi|ou|shampoo|spray|vlo)$
+
+ - rule: (blad|kind)$
+ replacement: \1eren
+ exceptions: (aanrecht|advertentie)blad
+
+ - rule: (ige)$
+ replacement: \1n
+
+ - rule: (allerg|bat|scop|fantas|fib|log|mal|metr|nest|nom|or|path)ie$
+ replacement: \1ieën
+ exceptions: approbatie
+
+ - rule: (alka|o)(l)ie?$
+ replacement: \1\2iën
+
+ - rule: (schip)$
+ replacement: schepen
+
+ - rule: (abort|act|acquisit|advis|amat|inspect)(eur)$
+ replacement: \1\2s
+
+ - rule: | (gevoel)$
+ replacement: \1ens
+
+ - rule: | (accent|agent)([-\s])(\w+)
+ replacement: \1s\2\3s
+
+ - rule: advocaat-(\w+)
+ replacement: advocaten-\1
+
+ - rule: (bike|borstel|distel|kabel|prikkel|winkel)$
+ replacement: \1s
+
+ - rule: | abraham, account, act, addict, adoptiefzoon, ah, ai, air, airstrip, alligator, amant, ampersand, analysator, animator, anklet, antiquair, arbeidspool,
+ (aar|aard|age|ah|bag|beignet|bike|chef|chon|club|e|é|eau|eër|el|em|en|eon|er|erd|festival|filet|film)$,
+ (foon|ie|ier|iër|kon|lation|lieu|lotion|marshal|nal|oir|oor|ose|ou|our|ount|pon|poo|prop|rak|rant|rn|sar|sion|sit|show|sor|spray)$,
+ (sun|tank|tant|test|um|view)$
+ replacement: \1s
+ exceptions: | a-attest, aar, aardster, aarlenaar, acceptant, adoptant, afgifte, albe, alge, allofoon, amandel, amarant, ante, antifoon, antipode, aquarel, arelaar,
+ ((aan|ge|ver|voor).*de|afe|ate|bel|bier|cel|contractant|denkende|deur|dier|dienaar|dode|eem|een|eel|eer|einde)$,
+ (ene|engel|gezwel|gier|iel|iem|isme|ïsme|jaar|ke|kel|krant|lem|lier|maatregel|migrant)$,
+ (model|officier|oïde|oor|oen|oer|eose|penaar|rivale|schel|schijnsel|sien|spier|ste|stel|stem|taar|tenaar|tier|tride|uaar|vaar|valide|verwante|vrage|zijde)$
+
+ - rule: (a|e|o|u)\1f$
+ replacement: \1ven
+ exceptions: (graaf|soof)$
+
+ - rule: (a|e|o|u)\1s$
+ replacement: \1zen
+
+ - rule: (ver|cijn)s$
+ replacement: \1zen
+
+ - rule: | (a|e|o|u)\1([^aeiou])$
+ replacement: \1\2en
+
+ - rule: | (aï|alia)(s),
+ ([^aeiou][aeiou])([^aeioux])$,
+ ^([aeiou])([^aeioux])$
+ replacement: \1\2\2en
+ exceptions: alcohol, amandel, apostel, dal, pad, slot, vat,
+ (blad|dag|dak|engel|gat|god|hertog|ij|kel|oorlog|proton|regel|schijnsel|schot|slag|tor|weg)$
+
+ - rule: (de|ene)$
+ replacement: \1n
+
+ - rule: f$
+ replacement: ven
+ exceptions: morf$
+
+ - rule: | ([aeiou]|aar|eur|ij)s$
+ replacement: \1zen
+ exceptions: (kaars|kruis)$
+
+ - rule: (lo)$
+ replacement: \1oien
+
+ - rule: (wei|zij)$
+ replacement: \1den
+
+ - rule: (e)$
+ replacement: \1n
+
+ - rule: $
+ replacement: en
+
+ irregular:
+ "accountant-administratieconsulent": "accountants-administratieconsulenten"
+ "agens" : "agentia"
+ "akkerman" : "akkerlieden"
+ "album amicorum" : "alba amicorum"
+ "ambachtsman" : "ambachtslieden"
+ "anchorman" : "anchormen"
+ "anchorwoman" : "anchorwomen"
+
+ uncountable:
+ - geld
+ - informatie
+ - rijst
+ - afrokapsel # according to WNT
1  rails/init.rb
@@ -0,0 +1 @@
+require "rich/pluralization"
11 tasks/rich_pluralization_tasks.rake
@@ -0,0 +1,11 @@
+
+namespace :rich_pluralization do
+ Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.verbose = false
+ t.test_files = FileList.new("vendor/plugins/rich_pluralization/test/**/*.rb") do |list|
+ # list.exclude "foo.rb"
+ end
+ end
+ Rake::Task["rich_pluralization:test"].comment = "Run the rich_pluralization plugin tests"
+end
24 test/core/string/inflections_test.rb
@@ -0,0 +1,24 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb"))
+
+module Rich
+ module Pluralization
+ module Test
+ module Core
+ module String
+
+ class InflectionsTest < ActiveSupport::TestCase
+ setup do
+ include Setup
+ I18n.locale = ::Rich::Pluralization::Engine.init(Locales::NL)
+ end
+
+ # test "pl" do
+ # assert true
+ # end
+ end
+ end
+
+ end
+ end
+ end
+end
20 test/engine_test.rb
@@ -0,0 +1,20 @@
+require "test_helper"
+
+module Rich
+ module Pluralization
+ module Test
+
+ class EngineTest < ActiveSupport::TestCase
+ setup do
+ include Setup
+ I18n.locale = ::Rich::Pluralization::Engine.init(Locales::NL)
+ end
+
+ # test "something" do
+ # assert true
+ # end
+ end
+
+ end
+ end
+end
60 test/locales/nl/inflections_test.rb
@@ -0,0 +1,60 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb"))
+require "csv"
+
+module Rich
+ module Pluralization
+ module Test
+ module Locales
+ module NL
+
+ class InflectionsTest < ActiveSupport::TestCase
+ setup do
+ include Setup
+ I18n.locale = ::Rich::Pluralization::Engine.init(self)
+ end
+
+ test "dutch_pluralizations" do
+ assert_equal "vinnen" , "vin".pl
+ assert_equal "tassen" , "tas".pl
+ assert_equal "telefoons" , "telefoon".pl
+ assert_equal "vragen" , "vraag".pl
+ assert_equal "huizen" , "huis".pl
+ assert_equal "brieven" , "brief".pl
+ assert_equal "broeken" , "broek".pl
+ assert_equal "tekens" , "teken".pl
+ assert_equal "begrafenissen" , "begrafenis".pl
+ assert_equal "diners" , "diner".pl
+ assert_equal "jubilea" , "jubileum".pl
+ assert_equal "festivals" , "festival".pl
+ assert_equal "vazen" , "vaas".pl
+ # assert_equal "vragen & antwoorden", "vraag & antwoord".pl
+ end
+
+ test "wnt_list" do
+ if File.exist?(filename = File.join(File.dirname(__FILE__), "words.csv"))
+
+ CSV.open(filename, "r", ",") do |word|
+ assert_equal word[1], word[0].pl unless word[1].match(/NULL/)
+ end
+
+ # passed, counted = 0, 0
+ #
+ # CSV.open(File.join(File.dirname(__FILE__), "words.csv"), "r", ",") do |word|
+ # unless word[1].match(/NULL/)
+ # counted = counted + 1
+ # passed = passed + 1 if word[1] == word[0].pl
+ # end
+ # end
+ #
+ # puts "Dutch word pluralization test results:"
+ # puts "Passed #{passed} of #{counted}"
+
+ end
+ end
+ end
+
+ end
+ end
+ end
+ end
+end
14 test/setup.rb
@@ -0,0 +1,14 @@
+
+module Rich
+ module Pluralization
+ module Test
+ module Setup
+
+ def self.included(base)
+ require "rich/pluralization"
+ end
+
+ end
+ end
+ end
+end
5 test/test_helper.rb
@@ -0,0 +1,5 @@
+require "rubygems"
+require "active_support"
+require "active_support/test_case"
+
+require File.join(File.dirname(__FILE__), "setup.rb")
1  uninstall.rb
@@ -0,0 +1 @@
+# Uninstall hook code here
Please sign in to comment.
Something went wrong with that request. Please try again.