Multilingual - special component class, which supports several languages
# You should subclass your real multi-lingual component class
package Podius::Component::MyMultilingual;
@ISA = qw(Podius::Component::Multilingual);
sub get_own_property_types ($) {
return [
[ is_enabled => MultilingualSelection, {
0 => { 0 => 'No', 1 => 'Yes' },
1 => { 0 => 'lo', 1 => 'ken' },
} ],
[ title => 'Scalar' ],
];
}
sub get_own_language_agnostic_property_names ($) {
return [ 'is_enabled' ];
}
package main;
use Podius;
use Podius::Component::MyMultilingual;
my $mlc = new Podius::Component::MyMultilingual;
$mlc->language(1); # or ->language_label('Hebrew')
$mlc->is_enabled(1);
$mlc->is_enabled_code(1); # the same thing
$mlc->is_enabled_label('ken'); # the same thing
print $mlc->is_enabled, "\n"; # prints 1
print $mlc->is_enabled_code, "\n"; # the same thing
print $mlc->is_enabled_label, "\n"; # prints 'ken'
This package implements superclass of components, supporting several languages in their properties. It supposes there are language-clone component collection of the one logical component. It sets active language for multi-lingual properties and synchronizes language-agnostic properties in language-clones of this component.
the Exception manpage, the Podius::Component::Publishable manpage, the Podius::Property::MultilingualLanguage manpage, the Podius::Property::VComponentCollection manpage.
* language_clones collection is set according to this component
* all language-agnostic properties are updated from this component
Note, no consistency of the collection is checked, the first matching component is returned. If you need all components in the specified language, use something like this instead:
my $french_clones = $component->language_clones
->filter(sub { $_[0]->language eq 'fr' })->get_all;
get_own_language_agnostic_property_names instead.