日本語パッチの内容公開

  • 投稿日:
  • by
  • カテゴリ:

このエントリはMovableType2.661を対象にしています。
MovableTypeの最新バージョン3.01は日本語パッチの必要がありません。
MT3.xのインストール手順についてはこちらを参考にしてください。

日本語化パッチをみなさまのご意見を取り入れながら頑張っていろいろと更新しておきながら、よく考えたら最終的にどんな感じになっているのかって書いていないことに気づきました。
現在の日本語化パッチでやっていることをまとめることにします。
Macユーザーでも、これを見ながら手作業をおこなえば対応できるでしょう。

赤字がパッチで修正している部分。
行数は、オリジナルの状態でカウントしたものです。行を追加したりしているので、作業を進めるにつれ行数が変化していくので要注意。
初版:2003/06/20
追加:2003/07/23
追加:2003/09/01
追加:2003/12/24 Ver2.65に対応
追加:2004/01/20 Ver2.661まで対応

    lib/MT/App/CMS.pm
  1. 9行目
    use Symbol;
    という行の前に
    use Jcode;
    という行を追加。
  2. 206行目以降を書き換え
    if ($page eq 'login.tmpl') {
        ## For bookmarklets, we need to pass-thru text, title, and
        ## href vars
        my $q = $app->{query};
        $param->{text} = $q->param('text');
        $param->{link_title} = $q->param('link_title');
        $param->{link_href} = $q->param('link_href');
        $param->{bm_show} = $q->param('bm_show');
    }
      ↓
    if ($page eq 'login.tmpl') {
        ## For bookmarklets, we need to pass-thru text, title, and
        ## href vars
        my $charset = {'Shift_JIS'=>'sjis','ISO-2022-JP'=>'jis','EUC-JP'=> 'euc',
                       'UTF-8'=>'utf8'}->{$app->{cfg}->PublishCharset} || 'utf8';

        my $q = $app->{query};
        $param->{text} = $q->param('text');
        $param->{link_title} = $q->param('link_title');
        $param->{link_href} = $q->param('link_href');
        $param->{text} = Jcode->new($param->{text})->$charset();
        $param->{link_title} = Jcode->new($param->{link_title})->$charset();
        $param->{link_href} = Jcode->new($param->{link_href})->$charset();

        $param->{bm_show} = $q->param('bm_show');
    }
  3. 629行目以降を書き換え
    if ($q->param('is_bm')) {
        $param{selected_text} = $param{text};
        $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
            scalar $q->param('link_title'),
            scalar $q->param('link_href'),
            scalar $q->param('link_title'),
            $param{text};
      ↓
    if ($q->param('is_bm')) {
        my $charset = {'Shift_JIS'=>'sjis','ISO-2022-JP'=>'jis','EUC-JP'=> 'euc',
                       'UTF-8'=>'utf8'}->{$app->{cfg}->PublishCharset} || 'utf8';

        $param{selected_text} = $param{text};
        $param{text} = sprintf qq(<a title="%s" href="%s">%s</a>\n\n%s),
            map { Jcode->new($_)->$charset() }
            scalar $q->param('link_title'),
            scalar $q->param('link_href'),
            scalar $q->param('link_title'),
  4. 646行目を書き換え
    $param{to_ping_url_loop} = $items;
      ↓
    $param{to_ping_url_loop} = [ grep { $_->{title} = Jcode->new($_->{title})->$charset() } @$items ];
  5. 1526行目を書き換え(2003/07/23追加)
    $row->{"status_$row->{status_text}"} = 1;
      ↓
    $row->{"status_" . MT::Entry::status_text($obj->status)} = 1;
  6. 2578行目を書き換え
    $body .= Text::Wrap::wrap("    ", "    ", $entry->get_excerpt) . "\n\n";   ↓
    $body .= (join "\n", (Jcode->new($entry->get_excerpt)->jfold($Text::Wrap::columns))) . "\n\n";
  7. 2585行目を書き換え
    $body .= Text::Wrap::wrap('', '', $entry->text) . "\n";   ↓
    $body .= (join "\n", (Jcode->new($entry->text)->jfold($Text::Wrap::columns))) . "\n";
  8. 2588行目を書き換え
    $subj =~ s![\x80-\xFF]!!g;
      ↓
    #$subj =~ s![\x80-\xFF]!!g;
    lib/MT/App/Trackback.pm
  1. 68行目以降を書き換え
        if (my $err = $param{Error}) {
            my $re = join '|', keys %map;
            $err =~ s!($re)!$map{$1}!g;
            print <<XML;
    <?xml version="1.0" encoding="iso-8859-1"?>
    <response>
    <error>1</error>
    <message>$err</message>
    </response>
    XML
        } else {
            print <<XML;
    <?xml version="1.0" encoding="iso-8859-1"?>
    <response>
    <error>0</error>
    XML
      ↓
        my $encoding = $app->{cfg}->PublishCharset || 'UTF-8';
        if (my $err = $param{Error}) {
            my $re = join '|', keys %map;
            $err =~ s!($re)!$map{$1}!g;
            print <<XML;
    <?xml version="1.0" encoding="$encoding"?>
    <response>
    <error>1</error>
    <message>$err</message>
    </response>
    XML
        } else {
            print <<XML;
    <?xml version="1.0" encoding="$encoding"?>
    <response>
    <error>0</error>
    XML
  2. 120行目以降を書き換え(2003/09/01変更)
    my($title, $excerpt, $url, $blog_name) = map scalar $q->param($_),
                                  qw( title excerpt url blog_name);

    no_utf8($tb_id, $title, $excerpt, $url, $blog_name);
      ↓
    my($title, $excerpt, $url, $blog_name, $icode) = map scalar $q->param($_),
                                  qw( title excerpt url blog_name charset);

    no_utf8($tb_id, $title, $excerpt, $url, $blog_name);
    require Jcode;
    my $charset = {'Shift_JIS'=>'sjis','ISO-2022-JP'=>'jis','EUC-JP'=>'euc',
                   'UTF-8'=>'utf8'}->{$app->{cfg}->PublishCharset} || 'utf8';
    my $incoming = {'shift_jis'=>'sjis','iso-2022-jp'=>'jis','euc-jp'=>'euc',
                    'utf-8'=>'utf8'}->{lc($icode)} || Jcode::getcode($excerpt . $title . $blog_name);
    $title = Jcode->new($title, $incoming)->$charset();
    $excerpt = Jcode->new($excerpt, $incoming)->$charset();
    $blog_name = Jcode->new($blog_name, $incoming)->$charset();

  3. 173行目移行を書き換え
    if (length($excerpt) > 255) {
        $excerpt = substr($excerpt, 0, 252) . '...';
    }
      ↓
    if (length($excerpt) > 255) {
        $excerpt = substr(Jcode->new($excerpt, $charset)->euc(), 0, 252);
        if ($excerpt =~ /\x8F$/ or $excerpt =~ tr/\x8E\xA1-\xFE// % 2) {
            chop $excerpt;
        }
        $excerpt = Jcode->new($excerpt . '...', 'euc')->$charset();

    }
  4. 273行目を書き換え
    <language>en-us</language>
      ↓
    <language>ja</language>
    lib/MT/ConfigMgr.pm
  1. 48行目を書き換え
    $mgr->define('BlogsPingURL', Default => 'http://ping.blo.gs/');
      ↓
    $mgr->define('BlogsPingURL', Default => 'http://ping.bloggers.jp/rpc/');
    lib/MT/Mail.pm
  1. 20行目以降を書き換え
    @{[ MT->version_slug ]}
    SIG
        my $mgr = MT::ConfigMgr->instance;
        my $xfer = $mgr->MailTransfer;
      ↓
    @{[ MT->version_slug ]}
    SIG
        require Jcode;
        $body = Jcode->new($body)->jis;
        $hdrs->{Subject} = Jcode->new($hdrs->{Subject})->mime_encode;
        $hdrs->{'Content-Type'} = qq(text/plain; charset="iso-2022-jp");
        $hdrs->{'Content-Transfer-Encoding'} = "7bit";

        my $mgr = MT::ConfigMgr->instance;
        my $xfer = $mgr->MailTransfer;
    lib/MT/XMLRPC.pm(EUC版のみ
  1. 47行目を書き換え
    my $blog_name = encode_xml($blog->name);
      ↓
    require Jcode;
    my $blog_name = encode_xml(Jcode->new($blog->name)->utf8);

    lib/MT/XMLRPCServer.pm(EUC版のみ
  1. 45行目
    use strict;
    という行の前に
    use Jcode;
    という行を追加。
  2. 125行目以降、196行目以降を書き換え
    unless ($HAVE_XML_PARSER) {
        for my $f (qw( title description mt_text_more
                       mt_excerpt mt_keywords )) {
            next unless defined $item->{$f};
            $item->{$f} = decode_html($item->{$f});
            $item->{$f} =~ s!'!'!g;
        }
    }
    my $mt = MT::XMLRPCServer::Util::mt_new(); ## Will die if MT->new fails.
      ↓
    unless ($HAVE_XML_PARSER) {
        for my $f (qw( title description mt_text_more
                       mt_excerpt mt_keywords )) {
            next unless defined $item->{$f};
            $item->{$f} = decode_html($item->{$f});
            $item->{$f} =~ s!'!'!g;
        }
    }

    for my $f (qw( title description mt_text_more mt_excerpt mt_keywords )) {
        next unless defined $item->{$f};
        $item->{$f} = Jcode->new($item->{$f},"utf8")->euc;
    }


    my $mt = MT::XMLRPCServer::Util::mt_new(); ## Will die if MT->new fails.
  3. 257行目を書き換え
    blogName => SOAP::Data->type(string => $blog->name) };
      ↓
    blogName => SOAP::Data->type(string => Jcode->new($blog->name)->utf8) };
  4. 268行目を書き換え
    my($fname, $lname) = split /\s+/, $author->name;
      ↓
    my($fname, $lname) = split /\s+/, Jcode->new($author->name)->utf8;
  5. 273行目を書き換え
    nickname => SOAP::Data->type(string => $author->nickname),
      ↓
    nickname => SOAP::Data->type(string => Jcode->new($author->nickname)->utf8),
  6. 305行目を書き換え
    $row->{content} = SOAP::Data->type(string => $entry->text);
      ↓
    $row->{content} = SOAP::Data->type(string => Jcode->new($entry->text)->utf8);
  7. 307行目を書き換え
    $row->{title} = SOAP::Data->type(string => $entry->title);
      ↓
    $row->{title} = SOAP::Data->type(string => Jcode->new($entry->title)->utf8);
  8. 309行目を書き換え
    $row->{description} = SOAP::Data->type(string => $entry->text);
      ↓
    $row->{description} = SOAP::Data->type(string => Jcode->new($entry->text)->utf8);
  9. 316行目以降を書き換え
    $row->{mt_text_more} = SOAP::Data->type(string => $entry->text_more);
    $row->{mt_excerpt} = SOAP::Data->type(string => $entry->excerpt);
    $row->{mt_keywords} = SOAP::Data->type(string => $entry->keywords);
      ↓
    $row->{mt_text_more} = SOAP::Data->type(string => Jcode->new($entry->text_more)->utf8);
    $row->{mt_excerpt} = SOAP::Data->type(string => Jcode->new($entry->excerpt)->utf8);
    $row->{mt_keywords} = SOAP::Data->type(string => Jcode->new($entry->keywords)->utf8);
  10. 368行目以降を書き換え
    description => SOAP::Data->type(string => $entry->text),
    title => SOAP::Data->type(string => $entry->title),
      ↓
    description => SOAP::Data->type(string => Jcode->new($entry->text)->utf8),
    title => SOAP::Data->type(string => Jcode->new($entry->title)->utf8),
  11. 375行目以降を書き換え
    mt_text_more => SOAP::Data->type(string => $entry->text_more),
    mt_excerpt => SOAP::Data->type(string => $entry->excerpt),
    mt_keywords => SOAP::Data->type(string => $entry->keywords),
      ↓
    mt_text_more => SOAP::Data->type(string => Jcode->new($entry->text_more)->utf8),
    mt_excerpt => SOAP::Data->type(string => Jcode->new($entry->excerpt)->utf8),
    mt_keywords => SOAP::Data->type(string => Jcode->new($entry->keywords)->utf8),
  12. 421行目を書き換え
    categoryName => SOAP::Data->type(string => $cat->label),
      ↓
    categoryName => SOAP::Data->type(string => Jcode->new($cat->label)->utf8),
  13. 444行目を書き換え
    categoryName => SOAP::Data->type(string => $cat->label),
      ↓
    categoryName => SOAP::Data->type(string => Jcode->new($cat->label)->utf8),
  14. 504行目を書き換え
    pingTitle => SOAP::Data->type(string => $ping->title),
      ↓
    pingTitle => SOAP::Data->type(string => Jcode->new($ping->title)->utf8),
    lib/MT.pm(2003/09/01追加)
  1. 560行目以降を書き換え
    ## Build query string to be sent on each ping.
    my @qs;
    push @qs, 'title=' . MT::Util::encode_url($entry->title);
    push @qs, 'url=' . MT::Util::encode_url($entry->permalink);
    push @qs, 'excerpt=' . MT::Util::encode_url($entry->get_excerpt);
    push @qs, 'blog_name=' . MT::Util::encode_url($blog->name);
    my $qs = join '&', @qs;
      ↓
    ## Build query string to be sent on each ping.
    require Jcode;
    my $charset = {'Shift_JIS'=>'sjis','ISO-2022-JP'=>'jis','EUC-JP'=>'euc',
                   'UTF-8'=>'utf8'}->{$mt->{cfg}->PublishCharset} || 'utf8';

    my @qs;
    push @qs, 'title=' . MT::Util::encode_url(Jcode->new($entry->title, $charset)->utf8);
    push @qs, 'url=' . MT::Util::encode_url(Jcode->new($entry->permalink, $charset)->utf8);
    push @qs, 'excerpt=' . MT::Util::encode_url(Jcode->new($entry->get_excerpt, $charset)->utf8);
    push @qs, 'blog_name=' . MT::Util::encode_url(Jcode->new($blog->name, $charset)->utf8);
    push @qs, 'charset=utf-8';
    my $qs = join '&', @qs;
    mt-check.cgi(2003/09/01追加)
    ※すでにmt-load.cgi実行済みの場合は、修正しても意味無し。
  1. 27行目移行を書き換え
    my @REQ = (
        [ 'HTML::Template', 2, 1, 'HTML::Template is required for all Movable Type application functionality.' ],
      ↓
    my @REQ = (
        [ 'Jcode', 0, 1, 'Jcode is required for Movable Type in Japanese.' ],

        [ 'HTML::Template', 2, 1, 'HTML::Template is required for all Movable Type application functionality.' ],
    tmpl/cms/cfg_prefs.tmpl(2003/12/24追加)
  1. 444行目を書き換え
    <input type="checkbox" name="ping_blogs" value="1"<TMPL_IF NAME=PING_BLOGS> checked</TMPL_IF>> <font class="title">blo.gs</font><br />
      ↓
    <input type="checkbox" name="ping_blogs" value="1"<TMPL_IF NAME=PING_BLOGS> checked</TMPL_IF>> <font class="title">ping.bloggers.jp</font><br />
    lib/MT/default-templates.pl
    ※すでにmt-load.cgi実行済みの場合は、修正しても意味無し。
  1. 252行目、616行目を書き換え
    <dc:language>en-us</dc:language>
      ↓
    <dc:language>ja</dc:language>
  2. 554行目、1258行目を書き換え
    <div style="width:180px; padding-right:15px; margin-right:15px; float:left; text-align:left; border-right:1px dotted #bbb;">
      ↓
    <!--div style="width:180px; padding-right:15px; margin-right:15px; float:left; text-align:left; border-right:1px dotted #bbb;"-->
  3. 563行目、1267行目を書き換え
    </div>
      ↓
    <!--/div-->
  4. 651行目から910行目、stylesheetっぽい部分をカミノゴウヤさん作のスタイルシート(EUCUTF-8)に書き換え
    styles.css
  1. ファイル自体をカミノゴウヤさん作のスタイルシート(EUCUTF-8)に書き換え
    lib/MT/L10N/ja.pm
  1. ひらたさん作のLanguagePackのうち、文字コードに適した方を新規作成
    images/lang-ja/*
  1. ひらたさん作の日本語用画像を新規作成