Changeset 54 for mt-i18n

Show
Ignore:
Timestamp:
04/24/05 19:16:22 (4 years ago)
Author:
ogawa
Message:

Add package declaration

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mt-i18n/trunk/mt-i18n.pl

    r50 r54  
    1 # MT-I18N plugin by Hirotaka Ogawa (http://as-is.net/blog/) 
     1# MT-I18N plugin for MT::I18N container tags and global filters 
    22# 
    3 # Release 0.01 (Aug 15, 2004) 
     3# Release 0.02 (Apr 24, 2005) 
    44# 
    55# This software is provided as-is. You may use it for commercial or  
     
    88# Copyright (c) 2004 Hirotaka Ogawa 
    99 
     10package MT::Plugin::I18N; 
    1011use strict; 
    1112use MT::Template::Context; 
    1213use MT::I18N; 
    1314 
    14 if (MT->can('add_plugin')) { 
     15eval("use Storable;"); 
     16if (!$@ && MT->can('add_plugin')) { 
    1517    require MT::Plugin; 
    1618    my $plugin = new MT::Plugin(); 
    17     $plugin->name("MT-I18N Plugin, v.0.01"); 
     19    $plugin->name("MT-I18N Plugin 0.02"); 
    1820    $plugin->description("Add MT::I18N container tags and global filters."); 
    1921    $plugin->doc_link("http://as-is.net/blog/archives/000900.html"); 
     
    7880    defined(my $text = $builder->build($ctx, $tokens)) 
    7981        or return $ctx->error($builder->errstr); 
    80     my $length = $args->{'length'}; 
    81     return MT::I18N::first_n_text($text, $length || 20); 
     82    my $length = $args->{'length'} || 20; 
     83    return (MT::I18N::length_text($text) > $length) ? 
     84        MT::I18N::first_n_text($text, $length) . '...' : $text; 
    8285}); 
    8386 
     
    8588    my ($text, $length, $ctx) = @_; 
    8689    $length ||= 20; 
    87     if (MT::I18N::length_text($text) > $length) { 
    88         return MT::I18N::first_n_text($text, $length) . '...'; 
    89     } else { 
    90         return $text; 
    91     } 
     90    return (MT::I18N::length_text($text) > $length) ? 
     91        MT::I18N::first_n_text($text, $length) . '...' : $text; 
    9292});