>
>From: Baptiste Ducatel <bip...@gm...>
>To: cpp...@li...
>Sent: Mon, January 10, 2011 6:00:46 PM
>Subject: [Cppcms-users] language specifies in sub-domains
>
>Hi,
>
>
>I would like to know how to manage sub-domains with cppcms,
>because our sub-domains contain the language of the website
>they look like:
> en.tatoeba.org
> fr.tatoeba.org
>
>
>They are "virtual" sub-domains, just to stock the language.
>
>
>Do you have any idea to configure cppcms and how can I get the language with
>urls.
>
>
You should use HTTP_HOST variable to get the domain.
See:
http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#0dc145f6fb337cd352c64a7011bd2142
Then you can extract it with regular expression or something like that.
I would overload cppcms::application::main and set the language there
and the "dispatch" urls as I need.
See for example how wikipp handles this:
http://cppcms.svn.sourceforge.net/viewvc/cppcms/wikipp/branches/for_cppcms_v100/wiki.cpp?revision=1615&view=markup
Just in your case you should do something like:
static const booster::regex lang_regex("([a-z]+)\\.tatoeba\\.org");
void your_app::main(std::string url)
{
// set language globally before dispatching
booster::smatchres;
std::string domain = request().http_host();
if(booster::regex_match(domain,res,lang_regex)){
std::string lang = res[1];
set_current_language(lang);
}
// now execute regular url dispatching.
cppcms::application::main(url);
}
>Thanks,
>Baptiste
Regards,
Artyom
P.S.: I also would be glad to hear how does it goes with converting tatoeba.org
to CppCMS.
|