NAME
Data::Localize::YAML - Acquire Lexicons From .yml Files
SYNOPSIS
my $loc = Data::Localize->new();
# with YAML lexicons in form of arrays of id/str keys in hashes
$loc->add_localizer(
class => 'YAML',
path => 'i18n/*.yaml',
);
# same, but change the keys
$loc->add_localizer(
class => 'YAML',
path => 'i18n/*.yaml',
array_key_value => [qw(msgid msgstr)],
);
# use hashes instead
$loc->add_localizer(
class => 'YAML',
path => 'i18n/*.yaml',
is_array => 0,
);
DESCRIPTION
This module is a plugin to Data::Localize which makes it possible to acquire lexicons from YAML files in the following formats:
array
The default format. Resembles how basic .po files look, but is easier to handle since it is YAML.
Key and value keys are by default id and str, which can be changed by passing array_key_value (a two element array with keys).
---
id: key
str: translation
---
id: key2
str: other translation
hash
Obtains simple key/value pairs from a hash
---
key: translation
key2: other translation
METHODS
format_string($lang, $value, @args)
Formats the string
add_path($path, ...)
Adds a new path where .po files may be searched for.
get_lexicon($lang, $id)
Gets the specified lexicon
set_lexicon($lang, $id, $value)
Sets the specified lexicon
merge_lexicon
Merges lexicon (may change...)
get_lexicon_map($lang)
Get the lexicon map for language $lang
set_lexicon_map($lang, \%lexicons)
Set the lexicon map for language $lang
load_from_file
Loads lexicons from specified file
load_from_path
Loads lexicons from specified path. May contain glob()'able expressions.
register
Registers this localizer
UTF8
Currently, strings are assumed to be utf-8,
SEE ALSO
AUTHOR
Bartosz Jarzyna bbrtj.pro@gmail.com
Parts of this code stolen from Data::Localize::Gettext.
COPYRIGHT
The "MIT" License