There are a couple different ways you could architect it.

One way would be to incorporate all the business logic into modules, 
and just invoke the module code from separate components.

Symlinking, as you mention, is another option.

Personally, I'd probably implement internationalization by putting 
another directory level under /eshop (EG /eshop/i18n/) and using a 
dhandler to select the appropriate translated strings out of a database 
(or tied hash) and call the necessary components from there.  Or use a 
framework which has internationalization baked in.

EG something like:
<%shared>
my ($asset,$function) = split /\//, $m->dhandler_arg;
my %i18n_asset = ( cart => 'english', warenkorb => 'german' );
my %i18n_function = (
   shipping  => 'shipping.mc',
   warenkorb => 'shipping.mc',
   checkout  => 'checkout.mc',
   kasse     => 'checkout.mc',
);

my $lang = $i18n_asset{$asset};
m$->redirect('/error/handler') unless defined($lang);

my $component = $i18n_function{$function};
$m->redirect('/error/handler') unless defined($component);

<& $component language => $lang &>
</%shared>


Note that I just threw this together as a rough guideline, it is not 
tested code.

The key point here is everything is data-driven.  In a non-trivial 
example the asset and function hashes would be defined globally 
(probably in a tied hash) rather than inline.  This way, we can add 
support for another language just by adding rows to a database, rather 
than having to write any new code or modify the site structure in any 
way.

There are other examples of how to do internationalization on the Mason 
book and Mason HQ sites.  There are also a plethora of i18n modules on 
CPAN.

Best practice is to sit down and think your site architecture through 
completely, and research how other people have solved the same sort of 
problem, before you start slinging code and creating components 
willy-nilly.


On 26.09.2012 11:04, T.Lawrance wrote:
> Hi all,
>
> What is the best way achieving translated url support with Poet? 
> Mean,
>
> in the english version of site want:   /eshop/cart/shipping
> e.g. german version should be:       /eshop/warenkorb/versand
>
>  the shipping.mc [1] and versand.mc [2] are doing the same thing, 
> only
> in different languages, and they are should be at different path, 
> like
> shipping.mc [3] should be in cart directory and versand.mc [4] should
> be in warenkorb directory. But the components are the same...
>
> What is the best practice in the Poet for url-translation?
> - doing many symbolic links? because the components must be files...
> - or try "somewhat" (don't know how, yet) rewriting urls in input to
> english version and at output to translated one (where to do this?) 
> in
> some middleware level, or at Poet level?
>
> Any ideas, please?
>
> thanx. ak.
>
>
>
> Links:
> ------
> [1] http://shipping.mc
> [2] http://versand.mc
> [3] http://shipping.mc
> [4] http://versand.mc


------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to