view release on metacpan or search on metacpan
src/ppport.h view on Meta::CPAN
adjust_stack_on_leave|||
alloc_maybe_populate_EXACT|||
alloccopstash|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_deref_call||5.013007|
amagic_i_ncmp|||
amagic_is_enabled|||
amagic_ncmp|||
src/ppport.h view on Meta::CPAN
cando|||
cast_i32||5.006000|
cast_iv||5.006000|
cast_ulong||5.006000|
cast_uv||5.006000|
check_locale_boundary_crossing|||
check_type_and_open|||
check_uni|||
check_utf8_print|||
checkcomma|||
ckWARN|5.006000||p
src/ppport.h view on Meta::CPAN
find_rundefsv||5.013002|
find_script|||
find_uninit_var|||
first_symbol|||n
foldEQ_latin1||5.013008|n
foldEQ_locale||5.013002|n
foldEQ_utf8_flags||5.013010|
foldEQ_utf8||5.013002|
foldEQ||5.013002|n
fold_constants|||
forbid_setid|||
src/ppport.h view on Meta::CPAN
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef_flags|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
src/ppport.h view on Meta::CPAN
ss_dup|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stdize_locale|||
strEQ|||
strGE|||
strGT|||
strLE|||
strLT|||
src/ppport.h view on Meta::CPAN
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_flags||5.013006|
sv_cmp_locale_flags||5.013006|
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm_flags||5.013006|
sv_collxfrm|||
sv_copypv_flags||5.017002|
sv_copypv_nomg||5.017002|
src/ppport.h view on Meta::CPAN
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
src/ppport.h view on Meta::CPAN
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Antsy.pm view on Meta::CPAN
OSC 1337 ; PopKeyLabels=[label] ST
Where [label] is an ASCII string that works best if it is unique in the stack.
=item * unicode_version
iTerm2 by default uses Unicode 9's width tables. The user can opt to use Unicode 8's tables with a preference (for backward compatibility with older locale databases). Since not all apps will be updated at the same time, you can tell iTerm2 to use a ...
OSC 1337 ; UnicodeVersion=[n] ST
Where [n] is 8 or 9
You can push the current value on a stack and pop it off to return to the previous value by setting n to push or pop. Optionally, you may affix a label after push by setting n to something like push mylabel. This attaches a label to that stack entry....
view all matches for this distribution
view release on metacpan or search on metacpan
0.05 2014-09-09 08:49:13 -0400
- promote to production
0.04_01 2014-08-21 13:34:15 -0400
- set LC_ALL=C in tests to avoid possible locale missmatches
0.04 2014-08-09 07:32:40 -0400
- make default for test timeout be 120s
0.03 2014-08-05 08:13:16 -0400
- fix for test failure on MSWin32
0.02 2014-08-05 07:20:55 -0400
- fix test failure on non C/English locales (thanks syohex)
- fix test on OS X (thanks ryochin)
0.01 2014-08-04 16:49:27 -0400
- initial version
view all matches for this distribution
view release on metacpan or search on metacpan
use strict;
use warnings;
use Test::More;
use Test::Exception;
use POSIX qw/setlocale/;
use t::Redis;
setlocale( &POSIX::LC_ALL, 'C' );
use ok 'AnyEvent::Hiredis';
test_redis {
my $port = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
1.142640 2014-09-21 19:14:14+01:00 Europe/London
- Documentation fixes. (Thanks to Toshio Ito.)
1.142230 2014-08-11 18:32:39+01:00 Europe/London
- Don't check locale-specific error message to avoid test failure.
1.142010 2014-07-20 13:35:48+01:00 Europe/London
- Fix message ids large than 16-bits. (Thanks to wnagele on github.)
1.141992 2014-07-18 14:36:30+01:00 Europe/London
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MSN.pm view on Meta::CPAN
lazy => 1
);
map { has $_->[0] => (is => 'ro', isa => 'Str', default => $_->[1]) }
[qw[product_id PROD0120PW!CCV9@]],
[qw[product_key C1BX{V4W}Q3*10SM]],
[qw[locale_id 0x0409]],
[qw[os_type winnt]],
[qw[os_ver 6.1.1]],
[qw[arch i386]],
[qw[client_name MSNMSGR]],
[qw[client_version 15.4.3508.1109]],
lib/AnyEvent/MSN.pm view on Meta::CPAN
$s->_set_protocol_version($r);
# Send basic client info
$s->send('CVR %d %s %s %s %s %s %s %s %s%s',
$s->tid,
$s->locale_id,
$s->os_type,
$s->os_ver,
$s->arch,
$s->client_name,
$s->client_version,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RabbitMQ.pm view on Meta::CPAN
my @mechanisms = split /\s/, $frame->method_frame->mechanisms;
return $args{on_failure}->('AMQPLAIN is not found in mechanisms')
if none {$_ eq 'AMQPLAIN'} @mechanisms;
my @locales = split /\s/, $frame->method_frame->locales;
return $args{on_failure}->('en_US is not found in locales')
if none {$_ eq 'en_US'} @locales;
$self->{_server_properties} = $frame->method_frame->server_properties;
$self->_push_write(
Net::AMQP::Protocol::Connection::StartOk->new(
lib/AnyEvent/RabbitMQ.pm view on Meta::CPAN
mechanism => 'AMQPLAIN',
response => {
LOGIN => $args{user},
PASSWORD => $args{pass},
},
locale => 'en_US',
),
);
$self->_tune(%args,);
},
view all matches for this distribution
view release on metacpan or search on metacpan
=item on_line => $cb->($string)
The only mandatory parameter - passes the callback that will receive lines
that are completed by the user.
The string will be in locale-encoding (a multibyte character string). For
example, in an utf-8 using locale it will be utf-8. There is no portable
way known to the author to convert this into e.g. a unicode string.
=item prompt => $string
The prompt string to use, defaults to C<< > >>.
view all matches for this distribution
view release on metacpan or search on metacpan
t/02input.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
# We need a UTF-8 locale to force libtermkey into UTF-8 handling, even if the
# system locale is not
# We also need to fool libtermkey into believing TERM=xterm even if it isn't,
# so we can reliably control it with fake escape sequences
BEGIN {
$ENV{LANG} .= ".UTF-8" unless $ENV{LANG} =~ m/\.UTF-8$/;
$ENV{TERM} = "xterm";
view all matches for this distribution
view release on metacpan or search on metacpan
_invlist_search|||n
_invlist_subtract|||
_invlist_union_maybe_complement_2nd|||
_invlist_union|||
_is_cur_LC_category_utf8|||
_is_in_locale_category||5.021001|
_is_uni_FOO||5.017008|
_is_uni_perl_idcont||5.017008|
_is_uni_perl_idstart||5.017007|
_is_utf8_FOO||5.017008|
_is_utf8_char_slow||5.021001|n
_load_PL_utf8_foldclosures|||
_make_exactf_invlist|||
_new_invlist_C_array|||
_new_invlist|||
_pMY_CXT|5.007003||p
_setlocale_debug_string|||n
_setup_canned_invlist|||
_swash_inversion_hash|||
_swash_to_invlist|||
_to_fold_latin1|||
_to_uni_fold_flags||5.014000|
_to_utf8_case|||
_to_utf8_fold_flags||5.019009|
_to_utf8_lower_flags||5.019009|
_to_utf8_title_flags||5.019009|
_to_utf8_upper_flags||5.019009|
_warn_problematic_locale|||n
aMY_CXT_|5.007003||p
aMY_CXT|5.007003||p
aTHXR_|5.024000||p
aTHXR|5.024000||p
aTHX_|5.006000||p
advance_one_WB|||
alloc_maybe_populate_EXACT|||
alloccopstash|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_deref_call||5.013007|
amagic_i_ncmp|||
amagic_is_enabled|||
amagic_ncmp|||
cando|||
cast_i32||5.006000|n
cast_iv||5.006000|n
cast_ulong||5.006000|n
cast_uv||5.006000|n
check_locale_boundary_crossing|||
check_type_and_open|||
check_uni|||
check_utf8_print|||
checkcomma|||
ckWARN|5.006000||p
find_script|||
find_uninit_var|||
first_symbol|||n
fixup_errno_string|||
foldEQ_latin1||5.013008|n
foldEQ_locale||5.013002|n
foldEQ_utf8_flags||5.013010|
foldEQ_utf8||5.013002|
foldEQ||5.013002|n
fold_constants|||
forbid_setid|||
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef_flags|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
my_memset|||n
my_pclose||5.003070|
my_popen_list||5.007001|
my_popen||5.003070|
my_setenv|||
my_setlocale|||
my_snprintf|5.009004||pvn
my_socketpair||5.007003|n
my_sprintf|5.009003||pvn
my_stat_flags|||
my_stat||5.024000|
space_join_names_mortal|||
ss_dup|||
ssc_add_range|||
ssc_and|||
ssc_anything|||
ssc_clear_locale|||n
ssc_cp_and|||
ssc_finalize|||
ssc_init|||
ssc_intersection|||
ssc_is_anything|||n
ssc_or|||
ssc_union|||
stack_grow|||
start_glob|||
start_subparse||5.004000|
stdize_locale|||
strEQ|||
strGE|||
strGT|||
strLE|||
strLT|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_flags||5.013006|
sv_cmp_locale_flags||5.013006|
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm_flags||5.013006|
sv_collxfrm|||
sv_copypv_flags||5.017002|
sv_copypv_nomg||5.017002|
swallow_bom|||
swash_fetch||5.007002|
swash_init||5.006000|
swash_scan_list_line|||
swatch_get|||
sync_locale||5.021004|
sys_init3||5.010000|n
sys_init||5.010000|n
sys_intern_clear|||
sys_intern_dup|||
sys_intern_init|||
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
add_range_to_invlist|||
add_utf16_textfilter|||
addmad|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_deref_call||5.013007|
amagic_i_ncmp|||
amagic_ncmp|||
anonymise_cv_maybe|||
find_rundefsv||5.013002|
find_script|||
find_uninit_var|||
first_symbol|||n
foldEQ_latin1||5.013008|n
foldEQ_locale||5.013002|n
foldEQ_utf8_flags||5.013010|
foldEQ_utf8||5.013002|
foldEQ||5.013002|n
fold_constants|||
forbid_setid|||
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef_flags|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.014000|
stdize_locale|||
store_cop_label|||
strEQ|||
strGE|||
strGT|||
strLE|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_flags||5.013006|
sv_cmp_locale_flags||5.013006|
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm_flags||5.013006|
sv_collxfrm|||
sv_compile_2op_is_broken|||
sv_compile_2op||5.008001|
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/DNS.pm view on Meta::CPAN
# there are many options to find the current nameservers etc. on windows
# all of them don't work consistently:
# - the registry thing needs separate code on win32 native vs. cygwin
# - the registry layout differs between windows versions
# - calling windows api functions doesn't work on cygwin
# - ipconfig uses locale-specific messages
# we use Net::DNS::Resolver first, and if it fails, will fall back to
# ipconfig parsing.
unless (eval {
# Net::DNS::Resolver uses a LOT of ram (~10mb), but what can we do :/
view all matches for this distribution
view release on metacpan or search on metacpan
dtds/dialog.dtd view on Meta::CPAN
<!ATTLIST dlg:formattedfield %default-attributes;
dlg:tabstop %boolean; #IMPLIED
dlg:readonly %boolean; #IMPLIED
dlg:align (left|center|right) #IMPLIED
dlg:format-code CDATA #IMPLIED
dlg:format-locale CDATA #IMPLIED
dlg:strict-format %boolean; #IMPLIED
dlg:value-default CDATA #IMPLIED
dlg:value-max %numeric; #IMPLIED
dlg:value-min %numeric; #IMPLIED
dlg:value %numeric; #IMPLIED
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Defaults.pm view on Meta::CPAN
$self->{platform} = $3;
} elsif (/^Server built:\s+(.+)/) {
$self->{built} =
DateTime::Format::Strptime->new(
pattern => '%b %d %Y %H:%M%S',
locale => 'en_US',
time_zone => 'UTC',
on_error => 'undef'
)->parse_datetime($1);
} elsif (/^Server loaded:\s+(.+)$/) {
view all matches for this distribution
view release on metacpan or search on metacpan
hv_scalar||5.009001|
hv_store_ent||5.004000|
hv_store_flags||5.008000|
hv_store|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incl_perldb|||
incline|||
incpush|||
sortsv||5.007003|
ss_dup|||
stack_grow|||
start_glob|||
start_subparse||5.004000|
stdize_locale|||
strEQ|||
strGE|||
strGT|||
strLE|||
strLT|||
sv_catsv|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm|||
sv_compile_2op||5.008001|
sv_copypv||5.007003|
sv_dec|||
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif /* PERL_VERSION */
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/LogFormat/Compiler.pm view on Meta::CPAN
=back
=head1 ABOUT POSIX::strftime::Compiler
This module uses L<POSIX::strftime::Compiler> for generate datetime string. POSIX::strftime::Compiler provides GNU C library compatible strftime(3). But this module will not affected by the system locale. This feature is useful when you want to write...
=head1 ADD CUSTOM FORMAT STRING
Apache::LogFormat::Compiler allows one to add a custom format string
view all matches for this distribution
view release on metacpan or search on metacpan
Most databases that understand multiple character sets have a
default global charset. Text stored in the database is, or should
be, stored in that charset; if not, then that's the fault of either
the database or the application that inserted the data. When text is
fetched it should be automatically converted to the charset of the
client, presumably based on the locale. If a driver needs to set a
flag to get that behaviour, then it should do so; it should not require
the application to do that.
Multiple SQL statements may not be combined in a single statement
handle (C<$sth>), although some databases and drivers do support this
view all matches for this distribution
view release on metacpan or search on metacpan
eg/contrib/bin/build_locale.pl view on Meta::CPAN
#!/usr/bin/perl -w
# $Id: build_locale.pl,v 1.1 2001/12/04 13:57:49 borisz Exp $
use strict;
use File::Path;
eg/contrib/bin/build_locale.pl view on Meta::CPAN
chomp( $msgfmt_cmd = `which msgfmt` );
$msgfmt_cmd =~ /^which: no/ and die "msgfmt not found!";
$root_dir = shift || die "$0 /full/path/to/your/documentroot";
$template_dir = $root_dir . '/contrib/locale/templates/po';
chdir $template_dir and opendir DIR, '.' or die "$!";
@catalog_files = grep { /\.po$/ && -f } readdir DIR;
closedir DIR;
for (@catalog_files) {
my ($lang) = /(.*)\.po$/;
my $catalog_dir = "$root_dir/locale/$lang/LC_MESSAGES";
mkpath($catalog_dir);
print "Create catalog $catalog_dir/PageKit.mo\n";
system( "$msgfmt_cmd", "-o", "$catalog_dir/PageKit.mo", "$_" ) == 0 or die "$msgfmt_cmd failed $?";
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/RandomImage.pm view on Meta::CPAN
Michael Kroell, C<< <pepl at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-locale-maketext-extract-plugin-xsl at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Locale-Maketext-Extract-Plugin-XSL>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
view all matches for this distribution
view release on metacpan or search on metacpan
Redirect.pod view on Meta::CPAN
=head1 DESCRIPTION
The purpose of this module is to give a tool to route local request to other web sites.
This module handles locale HTTP requests and it transfer them, pratically unchanged,
to other destination.
One of the use of this module is to permit to incapsulate, inside your own web site
structure , of external web application.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/SSI.pm view on Meta::CPAN
# Each entry is 1 when we've seen a true condition in this if-chain,
# 0 when we haven't. Initially it's as if we're in a big true
# if-block with no else.
'errmsg' => "[an error occurred while processing this directive]",
'sizefmt' => 'abbrev',
'timefmt' => undef, # undef means the current locale's default
}, $pack;
}
sub text {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/SdnFw/js/calendar_date_select/format_euro_24hr_ymd.js
lib/Apache/SdnFw/js/calendar_date_select/format_finnish.js
lib/Apache/SdnFw/js/calendar_date_select/format_hyphen_ampm.js
lib/Apache/SdnFw/js/calendar_date_select/format_iso_date.js
lib/Apache/SdnFw/js/calendar_date_select/format_italian.js
lib/Apache/SdnFw/js/calendar_date_select/locale/de.js
lib/Apache/SdnFw/js/calendar_date_select/locale/fi.js
lib/Apache/SdnFw/js/calendar_date_select/locale/fr.js
lib/Apache/SdnFw/js/calendar_date_select/locale/pl.js
lib/Apache/SdnFw/js/calendar_date_select/locale/pt.js
lib/Apache/SdnFw/js/calendar_date_select/locale/ru.js
lib/Apache/SdnFw/js/controls.js
lib/Apache/SdnFw/js/dragdrop.js
lib/Apache/SdnFw/js/effects.js
lib/Apache/SdnFw/js/prototype.js
lib/Apache/SdnFw/js/scriptaculous.js
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Validate/varchar.pm view on Meta::CPAN
# Be paranoid about using grouping!
my $digits = '(?:\d+)';
my $dot = '\.';
my $qm = '\?';
my $hex = '[a-fA-F\d]';
my $alpha = '[a-zA-Z]'; # No, no locale.
my $alphas = "(?:${alpha}+)";
my $alphanum = '[a-zA-Z\d]'; # Letter or digit.
my $xalphanum = "(?:${alphanum}|%(?:3\\d|[46]$hex|[57][Aa\\d]))";
# Letter or digit, or hex escaped letter/digit.
my $alphanums = "(?:${alphanum}+)";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Wombat/Connector.pm view on Meta::CPAN
$request->setRequestedSessionId($sessionID);
$request->setRequestedSessionCookie(undef);
$request->setRequestedSessionURL(1);
}
# locales
my $acceptLangHdr = $apr->header_in('Accept-Language');
for my $locale (Wombat::Util::RequestUtil->parseLocales($acceptLangHdr)) {
$request->addLocale($locale);
}
# cookies and maybe session ID stuff
my $cookieHdr = $apr->header_in('Cookie');
for my $cookie (Wombat::Util::RequestUtil->parseCookies($cookieHdr)) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/iNcom.pm view on Meta::CPAN
The language of the files without a language extension. Defaults to C<en>.
=item INCOM_LOCALE
The package uses to create Locale::Maketext(3) instance. If this is
set, an instance appropriate for the user's locale will be available
through the $Locale object.
=back
lib/Apache/iNcom.pm view on Meta::CPAN
User management is handled through the DBIx::UserDB(3) module.
=head1 LOCALIZATION
Apache::iNcom is designed to make it easy to adapt your e-commerce
application to multiple locale.
The framework uses Locale::Maketext(3) for message formatting.
All pages may have a localized version available. The localized should
have an extension describing its language. (.en for English, .fr for
French, .de for German, etc.)
The user locale will
be negotiated through the Accep-Language header which is part of the
HTTP protocol. It can also be set explicitely by sending the user to
a special link (since not many users took the time to configure their
browser for language negotiation).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache2/API.pm view on Meta::CPAN
}
if( !$msg->{lang} && $ex->can( 'lang' ) && ( $lang = $ex->lang ) )
{
$msg->{lang} = $lang;
}
elsif( !$msg->{lang} && $ex->can( 'locale' ) && ( $lang = $ex->locale ) )
{
$msg->{lang} = $lang;
}
warn( $msg->{message} ) if( $msg->{message} );
}
lib/Apache2/API.pm view on Meta::CPAN
# For example, if the message is a Text::PO::Gettext::String object
if( !$msg->{lang} && $self->_can( $msg->{message} => 'lang' ) )
{
$msg->{lang} = $msg->{message}->lang;
}
elsif( !$msg->{lang} && $self->_can( $msg->{message} => 'locale' ) )
{
$msg->{lang} = $msg->{message}->locale;
}
my $ctype = $self->response->content_type;
if( $ctype eq 'application/json' )
{
return( $self->reply( $msg->{code}, { error => $msg->{message} } ) );
lib/Apache2/API.pm view on Meta::CPAN
# {
# error => 'not_found',
# status => 404,
# title => 'Not found!',
# detail => q{The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.},
# locale => 'en-US',
# type => 'https://api.example.com/problems/not-found',
# }
# otherwise, the legacy approach would be:
# {
# error =>
# {
# code => 404,
# message => q{The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.},
# },
# locale => 'en-US',
# }
# $self->reply( Apache2::Const::HTTP_OK, { message => "All is well" } );
if( scalar( @_ ) == 2 )
{
( $code, $ref ) = @_;
lib/Apache2/API.pm view on Meta::CPAN
$code = $ex->code;
$ref =
{
message => $ex->message,
( $ex->can( 'public_message' ) ? ( public_message => $ex->public_message ) : () ),
( $ex->can( 'locale' ) ? ( locale => $ex->locale ) : () ),
};
}
# $self->reply({ code => Apache2::Const::HTTP_OK, message => "All is well" } );
elsif( ref( $_[0] ) eq 'HASH' )
{
lib/Apache2/API.pm view on Meta::CPAN
}
# Resolve whether this is an error
my $is_error = $resp->is_error( $code ) ? 1 : 0;
# NOTE: guess_preferred_locale() -> this is used to get he most appropriate locale if not defined already so we can, in turn, get the fallback description
my $guess_preferred_locale = sub
{
my $locale = shift( @_ );
if( !defined( $locale ) )
{
$locale = $req->preferred_language( Apache2::API::Status->supported_languages );
}
if( defined( $locale ) )
{
# Make sure we are dealing with unix style language code
$locale =~ tr/-/_/;
if( length( $locale ) == 2 )
{
$locale = Apache2::API::Status->convert_short_lang_to_long( $locale );
}
# We have something weird, like maybe eng?
elsif( $locale !~ /^[a-z]{2}_[A-Z]{2}$/ )
{
$locale = Apache2::API::Status->convert_short_lang_to_long( substr( $locale, 0, 2 ) );
}
}
return( $locale );
};
# NOTE: build_rfc_error() -> private subroutine to build the modern rfc9457 error payload
my $build_rfc_error = sub
{
my( $ref, $code, $msg ) = @_;
# By now, our property 'locale' has been dealt with, so we do not have to worry about it.
# It either exists or not
my $locale = exists( $ref->{locale} ) ? $ref->{locale} : undef;
# The property 'status' could exist, but be undefined, or even empty, so we check for that.
unless( exists( $ref->{status} ) &&
defined( $ref->{status} ) &&
length( $ref->{status} ) )
lib/Apache2/API.pm view on Meta::CPAN
ref( $ref->{error} ) eq 'HASH' &&
exists( $ref->{error}->{title} ) )
{
$ref->{title} = delete( $ref->{error}->{title} );
}
elsif( $locale )
{
$ref->{title} = Apache2::API::Status->status_message( $code => $locale );
}
else
{
$ref->{title} = Apache2::API::Status->status_message( $code );
}
lib/Apache2/API.pm view on Meta::CPAN
{
$ref->{detail} = "$msg";
}
else
{
my $fallback = $locale
? $resp->get_http_message( $code, $locale )
: $resp->get_http_message( $code );
$ref->{detail} = $fallback // 'An error occurred';
}
}
lib/Apache2/API.pm view on Meta::CPAN
# NOTE: build_legacy_error() -> private subroutine to build the legacy error payload
my $build_legacy_error = sub
{
my( $ref, $code, $msg ) = @_;
# By now, our property 'locale' has been dealt with, so we do not have to worry about it.
# It either exists or not
my $locale = exists( $ref->{error}->{locale} ) ? $ref->{error}->{locale} : undef;
# We set the property 'error' to be an HASH if not set already.
$ref->{error} = {} unless( exists( $ref->{error} ) && ref( $ref->{error} ) eq 'HASH' );
# The property 'code' could exist, but be undefined, or even empty, so we check for that.
unless( exists( $ref->{error}->{code} ) &&
lib/Apache2/API.pm view on Meta::CPAN
{
$ref->{error}->{code} = $code;
}
$ref->{error}->{code} = int( $ref->{error}->{code} ) if( $ref->{error}->{code} =~ /^\d+$/ );
# We try hard to get the value for the property 'message', but if $locale is undefined, it is impossible to find out the language that was used to formulate the response.
# So, ultimately, if we cannot find any value for the property 'message', we revert to guessing the HTTP caller's preferred language, which may, or may not be aligned with the content of other parts of the JSON response. Given that, in that s...
if( !exists( $ref->{error}->{message} ) ||
!defined( $ref->{error}->{message} ) ||
!length( $ref->{error}->{message} // '' ) )
{
if( defined( $msg ) &&
lib/Apache2/API.pm view on Meta::CPAN
last;
}
}
}
# Still nothing ? Get the fallback value using 'get_http_message' either using the $locale, if defined, or the HTTP caller's preferred language
if( !$ref->{error}->{message} )
{
$locale = $guess_preferred_locale->( $locale ) unless( defined( $locale ) );
my $fallback = $locale
? $resp->get_http_message( $code, $locale )
: $resp->get_http_message( $code );
$ref->{error}->{message} = $fallback // 'An error occurred';
}
}
lib/Apache2/API.pm view on Meta::CPAN
# Collapse top-level duplicates
delete( $ref->{ $_ } ) for( qw( message code type error_description ) );
};
# NOTE: set_payload_locale() -> find out and set the 'locale' property.
my $set_payload_locale = sub
{
my( $ref, $msg ) = @_;
my $locale;
# From message object
# '$msg' might be undef, and the method _is_a knows how to handle it.
if( $self->_is_a( $msg => 'Text::PO::String' ) )
{
$locale = $msg->locale
}
# Check if the Content-Language has already been set.
elsif( my $l = $resp->headers->get( 'Content-Language' ) )
{
$locale = $l;
$locale =~ tr/_/-/;
}
if( !defined( $locale ) &&
exists( $ref->{error} ) &&
ref( $ref->{error} ) eq 'HASH' )
{
foreach my $p ( qw( locale lang ) )
{
if( exists( $ref->{error}->{ $p } ) &&
defined( $ref->{error}->{ $p } ) &&
length( $ref->{error}->{ $p } ) )
{
$locale = $ref->{error}->{ $p };
last;
}
}
}
if( !defined( $locale ) )
{
foreach my $p ( qw( locale lang ) )
{
if( exists( $ref->{ $p } ) &&
defined( $ref->{ $p } ) &&
length( $ref->{ $p } ) )
{
$locale = $ref->{ $p };
last;
}
}
}
# If we found a locale, we set it properly whether it is an error or success message.
if( defined( $locale ) )
{
if( $is_error )
{
if( $use_rfc_error )
{
$ref->{locale} = $locale;
if( exists( $ref->{error} ) &&
ref( $ref->{error} ) eq 'HASH' )
{
delete( $ref->{error}->{lang} );
delete( $ref->{error}->{locale} );
}
}
else
{
$ref->{error} //= {};
$ref->{error}->{locale} = $locale;
delete( $ref->{lang} );
delete( $ref->{locale} );
}
}
else
{
$ref->{locale} = $locale;
}
}
return( defined( $locale ) ? 1 : 0);
};
# '$msg' may possibly be a Text::PO::String, whose benefit is that it has the 'locale' method
my $msg;
if( exists( $ref->{success} ) && !exists( $ref->{message} ) )
{
$msg = $ref->{success};
}
lib/Apache2/API.pm view on Meta::CPAN
{
$msg = $ref->{error};
$ref->{error} = {} unless( $use_rfc_error );
}
$set_payload_locale->( $ref, $msg );
if( $use_rfc_error )
{
$build_rfc_error->( $ref, $code, $msg );
}
lib/Apache2/API.pm view on Meta::CPAN
{
$ref->{success} = \1 unless( exists( $ref->{success} ) );
$ref->{code} //= $code;
$ref->{code} = int( $ref->{code} ) if( $ref->{code} =~ /^\d+$/ );
}
$set_payload_locale->( $ref, $msg );
}
# Or we just have a code to go on with
elsif( $is_error )
{
# No message, just a code => build minimal error body
lib/Apache2/API.pm view on Meta::CPAN
unless( $resp->headers->get( 'Cache-Control' ) )
{
$resp->headers->set( 'Cache-Control' => 'private, no-cache, no-store, must-revalidate' );
}
# If we have a locale set, we use it
my $locale;
if( $is_error )
{
if( $use_rfc_error )
{
$locale = $ref->{locale} if( exists( $ref->{locale} ) );
}
else
{
$locale = $ref->{error}->{locale} if( exists( $ref->{error} ) && ref( $ref->{error} ) eq 'HASH' && exists( $ref->{error}->{locale} ) );
}
}
# Success response
else
{
$locale = $ref->{locale} if( exists( $ref->{locale} ) );
}
if( $locale )
{
# Set the content language for this payload unless the user has already set it.
unless( $resp->headers->get( 'Content-Language' ) )
{
# en_GB -> en-GB
( my $hdr_locale = $locale ) =~ tr/_/-/;
$resp->headers->set( 'Content-Language' => $hdr_locale );
}
$resp->headers->merge( 'Vary' => 'Accept-Language' );
}
# Choose Content-Type
view all matches for this distribution
view release on metacpan or search on metacpan
aTHX|5.006000||p
add_data|||n
addmad|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_i_ncmp|||
amagic_ncmp|||
any_dup|||
ao|||
hv_store_ent||5.004000|
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.011000|
stdize_locale|||
store_cop_label|||
strEQ|||
strGE|||
strGT|||
strLE|||
sv_catxmlsv|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm|||
sv_compile_2op||5.008001|
sv_copypv||5.007003|
sv_dec|||
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
aTHX|5.006000||p
add_data|||n
addmad|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_i_ncmp|||
amagic_ncmp|||
any_dup|||
ao|||
hv_store_ent||5.004000|
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.011000|
stdize_locale|||
store_cop_label|||
strEQ|||
strGE|||
strGT|||
strLE|||
sv_catxmlsv|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm|||
sv_compile_2op||5.008001|
sv_copypv||5.007003|
sv_dec|||
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
aTHX|5.006000||p
add_data|||n
addmad|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_i_ncmp|||
amagic_ncmp|||
any_dup|||
ao|||
hv_store_ent||5.004000|
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incline|||
incpush_if_exists|||
incpush_use_sep|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.011000|
stdize_locale|||
store_cop_label|||
strEQ|||
strGE|||
strGT|||
strLE|||
sv_catxmlsv|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm|||
sv_compile_2op||5.008001|
sv_copypv||5.007003|
sv_dec|||
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
view all matches for this distribution
view release on metacpan or search on metacpan
eg/contrib/bin/build_locale.pl view on Meta::CPAN
#!/usr/bin/perl -w
# $Id: build_locale.pl,v 1.1 2001/12/04 13:57:49 borisz Exp $
use strict;
use File::Path;
eg/contrib/bin/build_locale.pl view on Meta::CPAN
chomp( $msgfmt_cmd = `which msgfmt` );
$msgfmt_cmd =~ /^which: no/ and die "msgfmt not found!";
$root_dir = shift || die "$0 /full/path/to/your/documentroot";
$template_dir = $root_dir . '/contrib/locale/templates/po';
chdir $template_dir and opendir DIR, '.' or die "$!";
@catalog_files = grep { /\.po$/ && -f } readdir DIR;
closedir DIR;
for (@catalog_files) {
my ($lang) = /(.*)\.po$/;
my $catalog_dir = "$root_dir/locale/$lang/LC_MESSAGES";
mkpath($catalog_dir);
print "Create catalog $catalog_dir/PageKit.mo\n";
system( "$msgfmt_cmd", "-o", "$catalog_dir/PageKit.mo", "$_" ) == 0 or die "$msgfmt_cmd failed $?";
}
view all matches for this distribution