Renamed $MOFILE to $MO_FILE, and $MOfile to $mo_file, for readability.

This commit is contained in:
依瑪貓 2019-09-09 19:53:18 +08:00
parent db7e22c83b
commit 9c1cdeed1e
2 changed files with 36 additions and 37 deletions

View File

@ -1,5 +1,5 @@
This file contains message digests of all files listed in MANIFEST, This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.55. signed via the Module::Signature module, version 0.81.
To verify the content in this distribution, first make sure you have To verify the content in this distribution, first make sure you have
Module::Signature installed, then type: Module::Signature installed, then type:
@ -26,7 +26,7 @@ SHA1 ec92e11b76afaa05f67d83a6e32056505a45c99e Makefile.PL
SHA1 b699f73f5fa33123b2f4f1b210665e295900c74d README SHA1 b699f73f5fa33123b2f4f1b210665e295900c74d README
SHA1 3db402b52e04cf5a6e60291c23aac8c16f2db810 THANKS SHA1 3db402b52e04cf5a6e60291c23aac8c16f2db810 THANKS
SHA1 85dd5ac895cc0a5b95827060999578d8ce8d41dd TODO SHA1 85dd5ac895cc0a5b95827060999578d8ce8d41dd TODO
SHA1 f9deac7b12cc6a3cb18b7f5282f9e6a1e1a624b9 lib/Locale/Maketext/Gettext.pm SHA1 b10574ec35614c629b52b87c6d92b4683a5c1a6d lib/Locale/Maketext/Gettext.pm
SHA1 b88b6bad1e8cb0ba825594c233c006c1b297646f lib/Locale/Maketext/Gettext/Functions.pm SHA1 b88b6bad1e8cb0ba825594c233c006c1b297646f lib/Locale/Maketext/Gettext/Functions.pm
SHA1 f89afd70fdcbaeeab44fada7ed3087d5c7f6f018 script/maketext SHA1 f89afd70fdcbaeeab44fada7ed3087d5c7f6f018 script/maketext
SHA1 525f414c7a0aadc61240a4b0959ca2cda7514c75 t/00-signature.t SHA1 525f414c7a0aadc61240a4b0959ca2cda7514c75 t/00-signature.t
@ -57,9 +57,8 @@ SHA1 bcc89cdc393507d51b5a76e40954db72914b60d8 t/locale/zh_TW/LC_MESSAGES/test2.m
SHA1 20f810c6229d0bd4064b27f9b3d86b61a20f0821 t/locale/zh_TW/LC_MESSAGES/test_be.mo SHA1 20f810c6229d0bd4064b27f9b3d86b61a20f0821 t/locale/zh_TW/LC_MESSAGES/test_be.mo
SHA1 eb13887b005e3c3e9fab774dfea22de5c01ad1ef t/locale/zh_TW/LC_MESSAGES/test_utf8.mo SHA1 eb13887b005e3c3e9fab774dfea22de5c01ad1ef t/locale/zh_TW/LC_MESSAGES/test_utf8.mo
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkpFc8MACgkQi9gubzC5S1w3kQCfY4bdMI9M6+sTT+y//sHibPDP iF0EARECAB0WIQSBin4eTeP7OclnnAOL2C5vMLlLXAUCXXY83QAKCRCL2C5vMLlL
LUUAnRvtrXrg1Tov/anLHx0Xur3TmAQQ XHVLAKCdSD4iKO//dkJljfF6dt3dIFTU5gCeKI8Kry3iISYdbcwVwMP80gff9Wg=
=Au1F =fz/R
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----

View File

@ -21,9 +21,9 @@ use Encode qw(encode decode FB_DEFAULT);
use File::Spec::Functions qw(catfile); use File::Spec::Functions qw(catfile);
no strict qw(refs); no strict qw(refs);
use vars qw(%Lexicons %ENCODINGS $REREAD_MO $MOFILE); use vars qw(%Lexicons %ENCODINGS $REREAD_MO $MO_FILE);
$REREAD_MO = 0; $REREAD_MO = 0;
$MOFILE = ""; $MO_FILE = "";
use vars qw(@SYSTEM_LOCALEDIRS); use vars qw(@SYSTEM_LOCALEDIRS);
@SYSTEM_LOCALEDIRS = qw(/usr/share/locale /usr/lib/locale @SYSTEM_LOCALEDIRS = qw(/usr/share/locale /usr/lib/locale
/usr/local/share/locale /usr/local/lib/locale); /usr/local/share/locale /usr/local/lib/locale);
@ -102,9 +102,9 @@ sub subclass_init : method {
$self->SUPER::fail_with($self->can("failure_handler_auto")); $self->SUPER::fail_with($self->can("failure_handler_auto"));
# Initialize the ENCODE_FAILURE setting # Initialize the ENCODE_FAILURE setting
$self->{"ENCODE_FAILURE"} = FB_DEFAULT; $self->{"ENCODE_FAILURE"} = FB_DEFAULT;
# Initialize the MOFILE value of this instance # Initialize the MO_FILE value of this instance
$self->{"MOFILE"} = ""; $self->{"MO_FILE"} = "";
${"$class\::MOFILE"} = "" if !defined ${"$class\::MOFILE"}; ${"$class\::MO_FILE"} = "" if !defined ${"$class\::MO_FILE"};
# Find the locale name, for this subclass # Find the locale name, for this subclass
$self->{"LOCALE"} = $class; $self->{"LOCALE"} = $class;
$self->{"LOCALE"} =~ s/^.*:://; $self->{"LOCALE"} =~ s/^.*:://;
@ -141,7 +141,7 @@ sub bindtextdomain : method {
# textdomain: Set the current text domain # textdomain: Set the current text domain
sub textdomain : method { sub textdomain : method {
local ($_, %_); local ($_, %_);
my ($self, $class, $DOMAIN, $LOCALEDIR, $MOfile); my ($self, $class, $DOMAIN, $LOCALEDIR, $mo_file);
($self, $DOMAIN) = @_; ($self, $DOMAIN) = @_;
# This is not a static method # This is not a static method
@ -160,41 +160,41 @@ sub textdomain : method {
# Clear it # Clear it
$self->{"Lexicon"} = {}; $self->{"Lexicon"} = {};
%{"$class\::Lexicon"} = qw(); %{"$class\::Lexicon"} = qw();
$self->{"MOFILE"} = ""; $self->{"MO_FILE"} = "";
${"$class\::MOFILE"} = ""; ${"$class\::MO_FILE"} = "";
# The format is "{LOCALEDIR}/{LOCALE}/{CATEGORY}/{DOMAIN}.mo" # The format is "{LOCALEDIR}/{LOCALE}/{CATEGORY}/{DOMAIN}.mo"
# Search the system locale directories if the domain was not # Search the system locale directories if the domain was not
# registered yet # registered yet
if (!exists ${$self->{"LOCALEDIRS"}}{$DOMAIN}) { if (!exists ${$self->{"LOCALEDIRS"}}{$DOMAIN}) {
undef $MOfile; undef $mo_file;
foreach $LOCALEDIR (@SYSTEM_LOCALEDIRS) { foreach $LOCALEDIR (@SYSTEM_LOCALEDIRS) {
$_ = catfile($LOCALEDIR, $self->{"LOCALE"}, $_ = catfile($LOCALEDIR, $self->{"LOCALE"},
$self->{"CATEGORY"}, "$DOMAIN.mo"); $self->{"CATEGORY"}, "$DOMAIN.mo");
if (-f $_ && -r $_) { if (-f $_ && -r $_) {
$MOfile = $_; $mo_file = $_;
last; last;
} }
} }
# Not found at last # Not found at last
return $DOMAIN if !defined $MOfile; return $DOMAIN if !defined $mo_file;
# This domain was registered # This domain was registered
} else { } else {
$MOfile = catfile(${$self->{"LOCALEDIRS"}}{$DOMAIN}, $mo_file = catfile(${$self->{"LOCALEDIRS"}}{$DOMAIN},
$self->{"LOCALE"}, $self->{"CATEGORY"}, "$DOMAIN.mo"); $self->{"LOCALE"}, $self->{"CATEGORY"}, "$DOMAIN.mo");
} }
# Record it # Record it
${"$class\::MOFILE"} = $MOfile; ${"$class\::MO_FILE"} = $mo_file;
$self->{"MOFILE"} = $MOfile; $self->{"MO_FILE"} = $mo_file;
# Read the MO file # Read the MO file
# Cached # Cached
if (!exists $ENCODINGS{$MOfile} || !exists $Lexicons{$MOfile}) { if (!exists $ENCODINGS{$mo_file} || !exists $Lexicons{$mo_file}) {
my $enc; my $enc;
# Read it # Read it
%_ = read_mo($MOfile); %_ = read_mo($mo_file);
# Successfully read # Successfully read
if (scalar(keys %_) > 0) { if (scalar(keys %_) > 0) {
@ -211,13 +211,13 @@ sub textdomain : method {
} }
# Cache them # Cache them
$Lexicons{$MOfile} = \%_; $Lexicons{$mo_file} = \%_;
$ENCODINGS{$MOfile} = $enc; $ENCODINGS{$mo_file} = $enc;
} }
# Respect the existing output encoding # Respect the existing output encoding
if (defined $ENCODINGS{$MOfile}) { if (defined $ENCODINGS{$mo_file}) {
$self->{"MO_ENCODING"} = $ENCODINGS{$MOfile}; $self->{"MO_ENCODING"} = $ENCODINGS{$mo_file};
} else { } else {
delete $self->{"MO_ENCODING"}; delete $self->{"MO_ENCODING"};
} }
@ -229,8 +229,8 @@ sub textdomain : method {
delete $self->{"ENCODING"}; delete $self->{"ENCODING"};
} }
} }
$self->{"Lexicon"} = $Lexicons{$MOfile}; $self->{"Lexicon"} = $Lexicons{$mo_file};
%{"$class\::Lexicon"} = %{$Lexicons{$MOfile}}; %{"$class\::Lexicon"} = %{$Lexicons{$mo_file}};
$self->clear_isa_scan; $self->clear_isa_scan;
return $DOMAIN; return $DOMAIN;
@ -260,8 +260,8 @@ sub maketext : method {
# single localization subclass whenever possible. # single localization subclass whenever possible.
# Maketext uses class lexicon in order to track the inheritance. # Maketext uses class lexicon in order to track the inheritance.
# It is hard to change it. # It is hard to change it.
if (${"$class\::MOFILE"} ne $self->{"MOFILE"}) { if (${"$class\::MO_FILE"} ne $self->{"MO_FILE"}) {
${"$class\::MOFILE"} = $self->{"MOFILE"}; ${"$class\::MO_FILE"} = $self->{"MO_FILE"};
%{"$class\::Lexicon"} = %{$self->{"Lexicon"}}; %{"$class\::Lexicon"} = %{$self->{"Lexicon"}};
} }
@ -299,14 +299,14 @@ sub pmaketext : method {
# Refer to gettext documentation section 8.3 # Refer to gettext documentation section 8.3
sub read_mo($) { sub read_mo($) {
local ($_, %_); local ($_, %_);
my ($MOfile, $len, $FH, $content, $tmpl); my ($mo_file, $len, $FH, $content, $tmpl);
$MOfile = $_[0]; $mo_file = $_[0];
# Avild being stupid # Avild being stupid
return unless -f $MOfile && -r $MOfile; return unless -f $mo_file && -r $mo_file;
# Read the MO file # Read the MO file
$len = (stat $MOfile)[7]; $len = (stat $mo_file)[7];
open $FH, $MOfile or return; # GNU gettext never fails! open $FH, $mo_file or return; # GNU gettext never fails!
binmode $FH; binmode $FH;
defined($_ = read $FH, $content, $len) defined($_ = read $FH, $content, $len)
or return; or return;
@ -535,7 +535,7 @@ If you want to have more control to the detail:
Use Locale::Maketext::Gettext to read and parse the MO file: Use Locale::Maketext::Gettext to read and parse the MO file:
use Locale::Maketext::Gettext; use Locale::Maketext::Gettext;
%Lexicon = read_mo($MOfile); %Lexicon = read_mo($mo_file);
=head1 DESCRIPTION =head1 DESCRIPTION
@ -653,7 +653,7 @@ are running a vital daemon, such as an X display server.
=over =over
=item %Lexicon = read_mo($MOfile); =item %Lexicon = read_mo($mo_file);
Read and parse the MO file. Returns the read %Lexicon. The returned Read and parse the MO file. Returns the read %Lexicon. The returned
lexicon is in its original encoding. lexicon is in its original encoding.