NAME
Nile::Lang - Language file manager.
SYNOPSIS
$lang = $self->me->lang;
# load language file from the current active or default language, file extension is xml.
$lang->load("general");
# load and append another language file
$lang->load("accounts");
# load language file of specific language.
$lang->load($file, $lang);
# get language variables from the active langauge
say $lang->get("site_name");
say $lang->get("first_name");
say $lang->get("last_name");
# get language variables of specific installed language.
say $lang->get("site_name", 'en-US');
# automatic getter support
say $lang->email; # same as $lang->get('email');
# get a group of language variables.
@text = $lang->list(@names);
# set language variables.
$lang->set("email_label", 'Email:');
$lang->set(%vars);
# automatic setter support
$lang->email('sales@mewsoft.com'); # same as $lang->set('email', 'sales@mewsoft.com');
DESCRIPTION
Nile::Lang - Language file manager.
file()
# set output file name for saving
$lang->file($file);
# get output file name
$file = $lang->file();
Get and set the output language file name used when saving or updating. The default file extension is xml.
encoding()
# get encoding used to read/write the language files, default is 'UTF-8'.
$encoding = $lang->encoding();
# set encoding used to read/write the langauge files, default is 'UTF-8'.
$lang->encoding('UTF-8');
Get and set encoding used to read/write the language files. The default encoding is 'UTF-8'.
load()
# load language file from the current active or default language, file extension is xml.
$lang->load("general");
# load and append another language file
$lang->load("accounts");
# load language file of specific language.
$lang->load($file, $lang);
Load language files from the current active or specific language The default file extension is xml. This method can be chained $lang-
load($file)->load($register)>;
lang()
# get active language for the language object.
$lang = $lang->lang();
# set active language for the language object.
$lang->lang("en-US");
Get and set active language used when loading or writing the language files.
clear()
# clear all loaded language data.
$lang = $lang->clear();
# clear all loaded language data of sepcific language.
$lang->clear("en-US");
Clear all loaded language data or sepcific language or all languages. This does not delete the data from files.
get()
# get language variables from the active langauge
say $lang->get("site_name");
say $lang->get("first_name");
say $lang->get("last_name");
# get language variables of specific installed language.
say $lang->get("site_name", 'en-US');
# automatic getter support
say $lang->email; # same as $lang->get('email');
Returns language variables from the active or specific installed language.
set()
# set language variables.
$lang->set("email_label", 'Email:');
$lang->set(%vars);
# automatic setter support
$lang->email('sales@mewsoft.com'); # same as $lang->set('email', 'sales@mewsoft.com');
Set language variables of the active language.
list()
# get a list of language variables.
@text = $lang->list(@names);
Set a list of language variables from the active language.
keys()
# returns all language variables names.
@names = $lang->keys($);
Returns all language variables names.
exists()
# check if a langugage variable exist or not.
$found = $lang->exists($name);
Check if a langugage variable exist or not.
delete()
# delete langugage variables.
$lang->delete(@names);
Delete a list of language variables.
get_file()
# returns language file data from the active or default language, default file extension is xml.
%data = $lang->get_file("contacts");
$data_ref = $lang->get_file("contacts");
# returns language file data from specific language, default file extension is xml.
%data = $lang->get_file("contacts", "en-US");
$data_ref = $lang->get_file("contacts", "en-US");
Returns language file data as a hash or hash reference from the active or specific language. The default file extension is xml.
save()
# write the output file.
$xml->save($file);
Save changes to the output file. If no file name it will update the loaded file name.
Bugs
This project is available on github at https://github.com/mewsoft/Nile.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Nile.
SOURCE
Source repository is at https://github.com/mewsoft/Nile.
AUTHOR
Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> Website: http://www.mewsoft.com
COPYRIGHT AND LICENSE
Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, https://github.com/mewsoft/Nile, http://www.mewsoft.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 196:
=cut found outside a pod block. Skipping to next block.