[Catalyst] get the path to the home
Octavian Rasnita
orasnita at gmail.com
Fri Sep 28 15:46:06 GMT 2007
From: "Chisel Wright" <chisel at herlpacker.co.uk>
On Fri, Sep 28, 2007 at 03:30:23PM +0300, Octavian Rasnita wrote:
> Hi,
>
> I have a I18N module in my Catalyst application and I want to get the path
> to the home directory of the application. Is it possible to get it without
> hard codding it in that module?
>
> The module is:
>
> package MyApp::I18N::ro;
> Assuming you can access to $c, I think this is what you want:
> $c->path_to(’’)
> It's described in 'perldoc Catalyst' and mentioned in 'perldoc
> Catalyst::Plugin::ConfigLoader'
> --
> Chisel Wright
Thank you but I know that. However, I have just the following module which
is not a controller or a model or a view:
# Copy/paste from Catalyst::Plugin::I18N:
#MyApp/I18N/de.pm
package MyApp::I18N::de;
use base 'MyApp::I18N';
our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
1;
So I don't have access to $c. Does this mean that I will need to hard code
the path to the home directory?
Here is what I want to do: I want to create a site in more languages, and it
is simple to use a .po file for translating short strings, however I also
need to display a few pages with pretty large descriptions, and I think I
can avoid using a database for this.
Instead of using .po files I want to use perl modules like ro.pm, de.pm and
so on, and in those files I want to define the translations as:
our %lexicon = (
'term' => 'translation',
'another term' => get_file('another_term',
);
sub get_file {
my $file = shift;
# read that file and return its content
}
I will keep those files in directories named with the language names like
de, ro, en, fr, and they will be placed in MyApp/lib/MyApp/I18N directory
(where the .pm or .po files should be also placed.
And I want to know if there is a way of getting that folder name without
hard codding it.
Thanks.
Octavian
More information about the Catalyst
mailing list