Interest in a more useful String#titlecase?

22 views
Skip to first unread message

Robb Shecter

unread,
Apr 7, 2012, 9:38:35 AM4/7/12
to facets-u...@googlegroups.com
I've written a custom #titleize for my Rails apps that'd make a good #titlecase enhancement. The major added value is that it follows English grammar rules for capitalizing titles. It also handles Unicode whitespace correctly:

  it "does a better titleize" do
    # The basic case
    "The dog is home".titleize.should == 'The Dog is Home'
    # Handle Unicode NBSP's
    "Fishery management".titleize.should == 'Fishery Management' # space
    "Fishery management".titleize.should == 'Fishery Management' # nbsp
  end

If there's interest, I can contribute it. One issue I see, though, is that it knows the English particles to not capitalize. I have no idea how to Internationalize this.

Trans

unread,
Apr 13, 2012, 4:54:45 PM4/13/12
to facets-u...@googlegroups.com
I'd be happy to take a look if you want to submit a pull request or just copy and paste the code here.

Reply all
Reply to author
Forward
0 new messages