[Catalyst] Choosing the language

Wade Stuart wbs at grepit.net
Wed Oct 14 16:05:10 GMT 2009


On Tue, Oct 13, 2009 at 9:35 AM, Pavel O. Korovkin <hippich at gmail.com>wrote:

> On Tue, Oct 13, 2009 at 4:16 PM, Octavian R=E2snita <orasnita at gmail.com>
> wrote:
> > From: "Larry Leszczynski" <larryl at emailplus.org>
> >>
> >> Hi (again) Octavian -
> >>
> >>> Is there a recommendation for storing the language ID in the URL in
> order
> >>> to
> >>> be as easy to get it from there?
> >>>
> >>> I want to have unique links for each URL, so I can't just put it in t=
he
> >>> cookies. Using ?lang=3DEN seems to be the easiest way, although it
> doesn't
> >>> look nice.
> >>>
> >>> Putting it as the first element in the path info looks nice, but I
> don't
> >>> know how to get it from there in a single controller/action and not in
> >>> every
> >>> action separately.
> >>
> >> Here is one way to have it in the URL without all controllers needing =
to
> >> be aware:
> >>
> >>   http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing
> >>
> >>
> >> HTH,
> >> Larry
> >
> > Thank you Larry. It seems to be what I need.
> >
> > I've seen some uses of $self which were not defined in that example.
> > Shouldn't be __PACKAGE__ instead?
> >
> > Unfortunately I don't know how to make it work in some cases:
> >
> > 1. If I use the test Catalyst server the static URLS that begin with
> /static
> > don't work because I can't configure that server to not handle /static
> URLS.
> > (But this is not so important).
> >
> > 2. Most important, if I need to use
> > [% c.uri_for('/static', 'css', 'layout.css') %]
> > for making it work even if I need to change the base location the app
> > handles, then the static files are not served by Apache directly but by
> the
> > app.
> >
> > If the app listens to the / location, the request is in this case:
> >
> > GET /en/static/css/layout.css HTTP/1.1
> >
> >
> >
> > I think I could make a hack somehow and configure Apache to do a request
> to
> > /static whenever the user tries to access /en/static or /fr/static... b=
ut
> I
> > guess this could be done with mod_rewrite which I don't know how to use
> yet.
> >
> >
> >
> > Is there a more simple method to make the web server serve the static
> files
> > directly?
> >
> >
> >
>
> Octavian,
>
> I think it's a "feature". Think about it if you will need different
> images for different languages, for example. Or RTL stylesheets for
> rtl languages. And you can use symlinks for now while you do not need
> these "features", or mod_rewrite to rewrite path to /static/ if there
> is no /en/static/ yet =3D)
>
>
    Might I also suggest splitting out Location from Language and treating
them as a key pair.  For instance,  http://example.com/us/en/foo/bar/.

    Just because two countries may speak Spanish does not mean their content
(and static assets like images!) would be the same --  they may very well
differ because of legal, cultural differences or local services/products.
Even if a site starts out with 100% translated/mirrored content,  it is
advisable to build flexibility into the url structure.

   Also,  depending on your roll out and domain plan,  take into
consideration that country specific domains should be able to publish the
country and language default content. http://example*.co.ae*/en/  serves ~
http://example.com/ae/en/.

-Wade



-- =

Thanks!

Wade Stuart

Phone:  917-363-6164
IM: SpaceMuscles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20091014/8f7f7=
2db/attachment.htm


More information about the Catalyst mailing list