Locale-VersionedMessages
view release on metacpan or search on metacpan
use Tk::ROText;
use Locale::Country;
use Locale::Language;
use I18N::LangTags::Detect;
###############################################################################
# GLOBAL VARIABLES
###############################################################################
our $message_set = 'lm_gui';
our $default_locale = "en_US";
our $default_dir = (-d "lib" ? "lib" : ".");
our $default_height = 400;
our $default_width = 600;
our $font_family = 'Helvetica';
our $font_weight = 'normal'; # medium bold ...
our $font_slant = 'roman'; # italic
our $font_size = '10'; # 8 12 ...
###############################################################################
# HELP
###############################################################################
=pod
=head1 NAME
lm_gui - simple GUI tool for managine Locale::VersionedMessages lexicons
=head1 SYNOPSIS
This tool can be used to maintain the lexicon files used by the
Locale::VersionedMessages perl module.
=head1 DESCRIPTION
The Locale::VersionedMessages module allows translation tables (i.e. lexicons) for
a set of message to be stored in perl modules to be used in a localized
program.
This tool allows you to create a new set of messages, add lexicons
(i.e. a lookup table for a locale), as well as add or update any
of the messages in the lexicons.
All messages should be entered (and will be stored) as UTF-8 text. Other
encodings are not currently supported.
=head1 LOCALIZED MESSAGES
This tool is localized using the Locale::VersionedMessages tools. It should
be noted that some of the messages contain markup (such as <b>...</b>).
This markup is NOT part of Locale::Mesasages. The markup is handled
internally by this program to make the GUI more user friendly.
=head1 KNOWN BUGS
Because I use standard Tk widgets to create the GUI, some of the
widgets do not exactly look like they ideally would. For example
when browsing for a Message Set Description file in the main window,
a popup appears with a <File name> entry and a <Files of type> menu.
Since we're only interested in .pm files, I would like to remove
the <Files of type> box, but that widget won't allow me to do so.
=head1 BUGS AND QUESTIONS
Please refer to the Locale::VersionedMessages documentation for information on
submitting bug reports or questions to the author.
=head1 SEE ALSO
Locale::VersionedMessages
=head1 LICENSE
This script is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 AUTHOR
Sullivan Beck (https://github.com/SBECK-github/)
=cut
###############################################################################
# MAIN PROGRAM
###############################################################################
# Main window and Frame handling based slightly on a message by zentara:
# http://www.perlmonks.org/?node_id=677105
# The main difference is that that posting kept creating new frames every
# time you switched which represents a memory leak. I create each frame once
# and reuse it.
our $lm = new Locale::VersionedMessages;
$lm->set($message_set);
my @loc = I18N::LangTags::Detect::detect();
my @l;
my %l;
foreach my $loc (@loc) {
if ($loc =~ /^(..)\-(..)$/) {
my($lc,$cc) = (lc($1),uc($2));
my $l = "${lc}_$cc";
if (! exists $l{$l}) {
push(@l,$l);
$l{$l} = 1;
}
if (! exists $l{$lc}) {
push(@l,$lc);
$l{$lc} = 1;
}
}
}
if (@l) {
$lm->search(@l);
}
( run in 1.239 second using v1.01-cache-2.11-cpan-364913b4093 )