Jump to content

How to redirect, and site translate?


DrMx
 Share

Recommended Posts

Hi

Im a designer with a WordPress background but i really want to migrate to ProcessWire, so i had been reading the docs for some weeks now, and just recently started to develop a local site.

What i have been struggling with ML is this:

1. I get to redirect the root site using htaccess, but works only for the root. Is there a way that can work for other pages?

ex. User enter "host/dir/content" and is redirected to "host/es/dir/content"

RewriteCond %{HTTP:Accept-Language} ^es [NC]
RewriteRule ^$ http://demohost/es [L,R=301]

2. I understand that Site Translation Files, are for my static template text?

ex. I have a default "index" static text, i can use STF to display "indice" in spanish instead?

If so, how do i create that file? I didn´t found info about that. If is for another use.. How and where do i translate my static template text?

I used to got it working in WordPress with some plugin and this kind of code, don´t know if i can use something like it in ProcessWire:

<?php _e("
  <!--:es-->indice<!--:-->
  <!--:en-->index<!--:-->
"); ?>

=o

Link to comment
Share on other sites

I'd suggest you read the first three of those linked topics here: http://processwire.com/api/multi-language-support/ 

The URL one does explain how you'd get those urls without doing anything to the .htaccess file. The first one does explain how the internationalization of static texts in templates work and the middle one is about how you can setup the fields for your dynamic content, so everything is language aware, too. 

  • Like 2
Link to comment
Share on other sites

Hi

Thanks for the links, i´m not a PHP expert so i got all day figuring out how to make the redirect in any page, that because i saw the options at the docs, but i think an automatic action could be better for many people. And just now got this to work:

$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if($lang == "es"){
	$var = substr($page->url,8,3); //8 cause im in localhost at the moment
	if($var != "es/"){
		header("location:".$page->localUrl("es"));
	}
}
else{echo "non spanish";}

If there is something i can improve please let me know, and i don´t know if it would work if being cached.

I don´t have any problems with fields.

Edit: I read the info at the internationalization link and have my answer now. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...