# number-spell.pl --- Movable Type 3 plugin to spell out numbers # (e.g., 1 => "one", 22 => "twenty-two") # # Copyright (C) 2005 Grant Hollingworth # # Permission to use, copy, modify, distribute, and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear in all copies and # that both that copyright notice and this permission notice appear in # supporting documentation. No representations are made about the # suitability of this software for any purpose. It is provided "as # is" without express or implied warranty. package MT::Plugin::Number::Spell; use strict; use MT; use MT::Template::Context; use vars qw( $VERSION ); $VERSION = (split / /, '$Id: number-spell.pl,v 1.12 2005/08/28 17:31:18 grant Exp $')[2]; my $name = "Number Spell"; # register plugin if ( MT->version_number >= 3 ) { require MT::Plugin; my $plugin = MT::Plugin->new( { name => $name, version => $VERSION, description => 'Spells out numbers', doc_link => 'http://antiflux.org/~grant/code/mt/number-spell/', }); MT->add_plugin( $plugin ); } # tags MT::Template::Context->add_global_filter( number_spell => \&spell ); # convert all integers into spelled-out numbers # don't use on decimal values or negative numbers sub spell { require Lingua::EN::Numbers; my $str = shift; $str =~ s/(\d+)/Lingua::EN::Numbers::num2en($1)/eg; return $str; }