NAME
Mo::utils::Language - Mo language utilities.
SYNOPSIS
use Mo::utils::Language qw(check_language_639_1 check_language_639_2);
check_language_639_1($self, $key);
check_language_639_2($self, $key);
DESCRIPTION
Mo language utilities for checking of data objects.
SUBROUTINES
check_language_639_1
check_language_639_1($self, $key);
Since version 0.05.
Check parameter defined by $key
if it's ISO 639-1 language code and if language code exists. Value could be undefined.
Returns undef.
check_language_639_2
check_language_639_2($self, $key);
Since version 0.05.
Check parameter defined by $key
if it's ISO 639-2 language code and if language code exists. Value could be undefined.
Returns undef.
ERRORS
check_language_639_1():
Parameter '%s' doesn't contain valid ISO 639-1 code.
Codeset: %s
Value: %s
check_language_639_2():
Parameter '%s' doesn't contain valid ISO 639-2 code.
Codeset: %s
Value: %s
EXAMPLE1
use strict;
use warnings;
use Mo::utils::Language qw(check_language_639_1);
my $self = {
'key' => 'en',
};
check_language_639_1($self, 'key');
# Print out.
print "ok\n";
# Output:
# ok
EXAMPLE2
use strict;
use warnings;
use Error::Pure;
use Mo::utils::Language qw(check_language_639_1);
$Error::Pure::TYPE = 'Error';
my $self = {
'key' => 'xx',
};
check_language_639_1($self, 'key');
# Print out.
print "ok\n";
# Output like:
# #Error [...utils.pm:?] Parameter 'key' doesn't contain valid ISO 639-1 code.
EXAMPLE3
use strict;
use warnings;
use Mo::utils::Language qw(check_language_639_2);
my $self = {
'key' => 'eng',
};
check_language_639_2($self, 'key');
# Print out.
print "ok\n";
# Output:
# ok
EXAMPLE4
use strict;
use warnings;
use Error::Pure;
use Mo::utils::Language qw(check_language_639_2);
$Error::Pure::TYPE = 'Error';
my $self = {
'key' => 'xxx',
};
check_language_639_2($self, 'key');
# Print out.
print "ok\n";
# Output like:
# #Error [...utils.pm:?] Parameter 'key' doesn't contain valid ISO 639-2 code.
DEPENDENCIES
Error::Pure, Exporter, List::Util, Locale::Language, Readonly.
SEE ALSO
- Mo
-
Micro Objects. Mo is less.
- Mo::utils
-
Mo utilities.
- Wikibase::Datatype::Utils
-
Wikibase datatype utilities.
REPOSITORY
https://github.com/michal-josef-spacek/Mo-utils-Language
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2022-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.08