Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated doc + made release ready

  • Loading branch information...
commit 967cf46ee77975cc354fa1132aa99380716f0adb 1 parent 0484002
Matt Aimonetti authored May 27, 2008
2  License.txt
... ...
@@ -1,4 +1,4 @@
1  
-Copyright (c) 2008 FIXME full name
  1
+Copyright (c) 2008 Matt Aimonetti
2 2
 
3 3
 Permission is hereby granted, free of charge, to any person obtaining
4 4
 a copy of this software and associated documentation files (the
7  Manifest.txt
@@ -6,8 +6,8 @@ Rakefile
6 6
 config/hoe.rb
7 7
 config/requirements.rb
8 8
 lib/han-converter.rb
  9
+lib/converter_table.rb
9 10
 lib/han-converter/version.rb
10  
-lib/han-converter.rb
11 11
 log/debug.log
12 12
 script/destroy
13 13
 script/generate
@@ -16,8 +16,9 @@ setup.rb
16 16
 tasks/deployment.rake
17 17
 tasks/environment.rake
18 18
 tasks/website.rake
19  
-test/test_han-converter.rb
20  
-test/test_helper.rb
  19
+spec/han-converter_spec.rb
  20
+spec/spec.opts
  21
+spec/spec_helper.rb
21 22
 website/index.html
22 23
 website/index.txt
23 24
 website/javascripts/rounded_corners_lite.inc.js
23  README.txt
... ...
@@ -1 +1,22 @@
1  
-README
  1
+Converts traditional to simplified Chinese and vice versa.
  2
+
  3
+Installation:
  4
+--------------
  5
+sudo gem install matta-han-converter --source=http://gems.github.com
  6
+
  7
+Usage:
  8
+------
  9
+
  10
+>> require 'han-converter'
  11
+=> true
  12
+>> "在您的手機上觀看和上載 YouTube 影片".to_simplified
  13
+=> "在您的手机上观看和上载 YouTube 影片"
  14
+
  15
+>> "在您的手机上观看和上载 YouTube 影片".to_traditional
  16
+=> "在您的手機上觀看咊上載 YouTube 影片"
  17
+
  18
+It won't be as good as manual translation but it works ok for me. The speed can probably be improved by going down to C land, but I don't have time to do that right now and I probably won't really need the speed for a little while.
  19
+
  20
+-Matt
  21
+
  22
+matt aimonetti [at] gmailDotCom
2  config/hoe.rb
@@ -31,7 +31,7 @@ def rubyforge_username
31 31
 REV = nil 
32 32
 # UNCOMMENT IF REQUIRED: 
33 33
 # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34  
-VERS = Han-converter::VERSION::STRING + (REV ? ".#{REV}" : "")
  34
+VERS = HanConverter::VERSION::STRING + (REV ? ".#{REV}" : "")
35 35
 RDOC_OPTS = ['--quiet', '--title', 'han-converter documentation',
36 36
     "--opname", "index.html",
37 37
     "--line-numbers", 
10  lib/han-converter.rb
@@ -13,6 +13,16 @@ def to_simplified
13 13
     end.join('')
14 14
   end
15 15
   
  16
+  def to_traditional
  17
+    self.chars.split(//).map do |char|
  18
+      if new_char_h = traditional_to_simplified.detect{|k,v| v == char.string}
  19
+        new_char_h.first
  20
+      else
  21
+        char.string
  22
+      end
  23
+    end.join('')
  24
+  end
  25
+  
16 26
 end
17 27
 
18 28
 class String
6  lib/han-converter/version.rb
... ...
@@ -1,8 +1,8 @@
1  
-module Han-converter #:nodoc:
  1
+module HanConverter #:nodoc:
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 0
4  
-    MINOR = 0
5  
-    TINY  = 1
  4
+    MINOR = 1
  5
+    TINY  = 0
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
22  spec/han-converter_spec.rb
... ...
@@ -0,0 +1,22 @@
  1
+require File.dirname(__FILE__) + '/spec_helper.rb'
  2
+
  3
+describe "han-converter" do
  4
+  
  5
+  it "should convert a traditional string into simplified Chinese" do
  6
+    "關於我們".to_simplified.should == "关於我们"
  7
+  end
  8
+  
  9
+  it "should handle spacing in a string" do
  10
+    "在您的手機上觀看和上載 YouTube 影片。".to_simplified.should == "在您的手机上观看和上载 YouTube 影片。"
  11
+  end
  12
+  
  13
+  it "should convert simplified to traditional" do
  14
+    "关於我们".to_traditional.should == "關於我們"
  15
+  end
  16
+  
  17
+  it "should handle none chinese chars to" do
  18
+    "ceci est un test".to_simplified.should == "ceci est un test"
  19
+    "l'école de Ruby".to_simplified.should == "l'école de Ruby"
  20
+  end
  21
+  
  22
+end
1  spec/spec.opts
... ...
@@ -0,0 +1 @@
  1
+--colour
9  spec/spec_helper.rb
... ...
@@ -0,0 +1,9 @@
  1
+begin
  2
+  require 'spec'
  3
+rescue LoadError
  4
+  require 'rubygems'
  5
+  gem 'rspec'
  6
+  require 'spec'
  7
+end
  8
+
  9
+require File.dirname(__FILE__) + '/../lib/han-converter.rb'
11  test/test_han-converter.rb
... ...
@@ -1,11 +0,0 @@
1  
-require File.dirname(__FILE__) + '/test_helper.rb'
2  
-
3  
-class TestHan-converter < Test::Unit::TestCase
4  
-
5  
-  def setup
6  
-  end
7  
-  
8  
-  def test_truth
9  
-    assert true
10  
-  end
11  
-end
2  test/test_helper.rb
... ...
@@ -1,2 +0,0 @@
1  
-require 'test/unit'
2  
-require File.dirname(__FILE__) + '/../lib/han-converter'

0 notes on commit 967cf46

Please sign in to comment.
Something went wrong with that request. Please try again.