Closed Akron closed 9 years ago
Sorry, I can't understand :-) Can you show me example of code?
Hi, thanks for your quick reply - I'll try to give an example. Let's say I've got a simple plugin ...
Mojolicious::Plugin::IamI18nAware;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
my ($self, $mojo) = @_;
$mojo->helper(
login => sub {
my $c = shift;
my $pwd = shift;
return 1 if $pwd eq 'p4ssw0rd';
$c->stash(error => $c->l('The password was wrong'));
return;
}
);
};
1;
... and I want to return a textual message generated by that plugin using M::P::I18N. I have a lot of translations for my message - how can I bundle them? Regarding templates and static assets, the solution is using path arrays for searching assets (http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Bundling_assets_with_plugins) - is there a similar method to bundle lexicon files with plugins?
Okay, check out this script:
https://github.com/sharifulin/mojolicious-plugin-i18n/blob/master/script/another_plugin.pl
It's dirty solution, but it works.
Thank you for that example. I think, your approach might work, however - native support in the plugin would be nice!
As far as I can see there is currently no option to bundle separated lexicons with a i18n aware plugin. This may be possible by providing a namespace array similar to Mojolicious::Plugins.
If I am wrong and there is a way in bundling lexicons with plugins, it should be named in the readme.
Thank you very much for maintaining this module!