NAME
CatalystX::I18N::Role::Collate - Support for localised collation
SYNOPSIS
package MyApp::Catalyst;
use Catalyst qw/MyPlugins
CatalystX::I18N::Role::Base
CatalystX::I18N::Role::Collate/;
package MyApp::Catalyst::Controller::Main;
use strict;
use warnings;
use parent qw/Catalyst::Controller/;
sub action : Local {
my ($self,$c) = @_;
$c->locale('de');
@sorted_names = $c->i18n_sort(qw/Algerien Ägypten Armenien Argentinien Äthiopien Afganistan Aserbaidschan/);
$c->stash->{names} = \@sorted_names;
}
DESCRIPTION
This role adds support for localised collation your Catalyst application.
my @german_alphabeth = (A..Z,a..z,'ä','Ä','ü','Ü','ö','Ö','ß');
$sort = join(',',sort @german_alphabeth);
# $sort_no_collate is 'A,B,C,[...],Z,a,b,c,[...],z,Ä,Ö,Ü,ß,ä,ö,ü'
$sort_localised = join(',',$c->i18n_sort(@german_alphabeth));
# $sort_no_collate is 'a,A,ä,Ä,b,B,c,C,[...],s,S,ß,t,T,u,U,ü,Ü,v,V,w,[...],z,Z'
All methods are lazy. This means that the values will be only calculated upon the first call of the method.
METHODS
i18n_sort
my @sorted = $c->i18n_sort(@list);
OR
my $sorted = $c->i18n_sort(\@list);
Sorts the given list or arrayref with the current locale and returns a list or arrayref.
i18n_collator
my $collator = $c->i18n_collator();
Returns a Unicode::Collate::Locale object with the current language used as the locale. The collator settings can be configured in your Catalyst I18N configuration:
# Add some I18N configuration
__PACKAGE__->config(
name => 'MyApp',
I18N => {
default_locale => 'de_AT',
locales => {
'de_AT' => {
collate => {
level => 3,
variable => 'Non-Ignorable',
...
},
},
}
},
);
The following configuration options are available (see Unicode::Collate for detailed documentation):
UCA_Version
alternate
backwards
entry
hangul_terminator
ignoreChar
katakana_before_hiragana
level
normalization
overrideCJK
overrideHangul
preprocess
rearrange
suppress
table
undefName
undefChar
upper_before_lower
variable
SEE ALSO
AUTHOR
Maroš Kollár
CPAN ID: MAROS
maros [at] k-1.com
L<http://www.revdev.at>