gpt4 book ai didi

perl - Locale::Maketext::Simple 的警告消息

转载 作者:行者123 更新时间:2023-12-04 22:56:43 25 4
gpt4 key购买 nike

我在启动程序时收到这些警告消息:

Name "AAT::Translation::I18N::en_us::Lexicon" used only once: possible typo at /usr/share/perl/5.12/Locale/Maketext.pm line 404.
Name "Win32::Locale::Lexicon" used only once: possible typo at /usr/share/perl/5.12/I18N/LangTags/Detect.pm line 140.

我的程序使用一个带有 Locale::Maketext::Simple 的模块:

use Locale::Maketext::Simple(
Path => '/usr/share/aat/Translations/'
);

此目录包含我的 *.po 文件(en.po、fr.po ...)

在使用 Perl 5.12/Locale::Maketext::Simple 0.21 之前我没有收到任何警告...

有什么办法可以解决这个问题吗?

编辑 1: 完整代码

package AAT::Translation;

use strict;
use warnings;
use Readonly;

use AAT::Utils qw( NULL );

my %AAT_Translation = ();

use Locale::Maketext::Simple(
Path => '/usr/share/aat/Translations/'
);

sub Init
{
my $lang = shift;

loc_lang($lang);
$AAT_Translation{$lang}{'_USER'} = loc("_USER");

return (1);
}

sub Get
{
my ($lang, $str) = @_;

return (undef) if (NULL($str));
Init($lang) if (!defined $AAT_Translation{$lang}{'_USER'});
$AAT_Translation{$lang}{$str} = (loc($str) || $str)
if (!defined $AAT_Translation{$lang}{$str});

return ($AAT_Translation{$lang}{$str});
}

编辑 2: 当然,如果我创建一个链接 en_us.po -> en.po,我不会得到“AAT::Translation::I18N::en_us::Lexicon”不再有错误消息,只有“Win32::Locale::Lexicon”错误消息,但这不是一个选项...

最佳答案

您看到的警告消息是在变量仅使用一次时生成的。例如:

perl -w -e '$var = "value";'
Name "main::var" used only once: possible typo at -e line 1.

参见 perldiag了解更多信息。

Locale::MaketextI18N::LangTags::Detect使用相同的代码作为 require Modulename 的包装器,正是这段代码生成了警告。芯Locale::MaketextI18N::LangTags::Detect模块已通过补丁修复 v5.13.9-153-g364c63c - 查看 no warnings 'once' 行:

Summary of changes:
dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm | 1 +
dist/Locale-Maketext/lib/Locale/Maketext.pm | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm b/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm
index 87280b7..e767aac 100644
--- a/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm
+++ b/dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm
@@ -136,6 +136,7 @@ sub _try_use { # Basically a wrapper around "require Modulename"

my $module = $_[0]; # ASSUME sane module name!
{ no strict 'refs';
+ no warnings 'once';
return($tried{$module} = 1)
if %{$module . "::Lexicon"} or @{$module . "::ISA"};
# weird case: we never use'd it, but there it is!
diff --git a/dist/Locale-Maketext/lib/Locale/Maketext.pm b/dist/Locale-Maketext/lib/Locale/Maketext.pm
index 042ecf7..b429778 100644
--- a/dist/Locale-Maketext/lib/Locale/Maketext.pm
+++ b/dist/Locale-Maketext/lib/Locale/Maketext.pm
@@ -439,6 +439,7 @@ sub _try_use { # Basically a wrapper around "require Modulename"

my $module = $_[0]; # ASSUME sane module name!
{ no strict 'refs';
+ no warnings 'once';
return($tried{$module} = 1)
if %{$module . '::Lexicon'} or @{$module . '::ISA'};
# weird case: we never use'd it, but there it is!

--

standalone version of Locale::Maketext 1.19 包含此补丁。然而,standalone version of I18N::LangTags::Detect似乎不包括补丁。我认为这意味着您需要升级您的 Perl 副本才能获得最新的核心 I18N::LangTags::Detect .更新单个核心模块可能是可能的,但我对它的了解还不够肯定 - 这些问题可能会有所帮助:

How can I safely compile a Perl 5.12 module for Perl 5.8.9?
How can I install a CPAN module that is in the latest perl, without installing the new perl?

关于perl - Locale::Maketext::Simple 的警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6983173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com