We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Simple Translator (formerly known as Another Language Switcher)

Development and Programming

Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

textdriven,

Since global variables work now, you could use them to hold the embedded template name. The global variable would contain its own name as the variable.

{embed="global/{communication}"}

Does that make sense?

ps. I haven’t tested this myself.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Excellent idea Cocoaholic!

<strike>If it works i would absolutely recommend going that way. I think the way the EE conditionals work; if you have two embeds in an if then an else, it will parse both embeds before running the conditional, not very elegant but that’s the way it is. That means if your conditional is 10 embeds long you’ll parse 10 pages for each page view. (Can someone confirm this? Check your SQL log on a page using conditionals to embed pages and you’ll see queries from the pages that aren’t being called). If it is the case using a variable in the embed should remedy this.</strike>

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Ok, I jumped the gun. I just tested out my theory above and in fact the embeds are run after the conditional, so it really shouldn’t matter which way you go.

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo

Once again this was exactly what I needed. Great work!

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Glad to hear it. Be sure to post what you’ve come up with!

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo

You may be able to see it already if the DNS has reached you..

I used your great work here http://www.exaprotect.com/resources/newsletters to switch the language of the newsletter and articles

I also used your fantastic pages module on this site

I’ll put it up in the site introductions with a credit for you once I’m sure the DNS has washed through and after a couple of days of bedding in.

THANK YOU MARK!

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

it looks great. is there a reason though that there’s so much redirecting? it pushes me back to the ‘site/newsletter’ page before sending me back again to the ‘resources/newsletters’ page i was on.

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo

Yes that was an issue I’m looking to resolve.

I’m using already using an .htaccess rewrite on the newsletter page

As the switcher extension builds the URL from Segments switching languages was sending it back to /site/etc…

So the quick and dirty solution was to redirect it back. Not ideal and something to tidy up after the launch.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Strange, because if you’re on the resources/newsletters page the extension should just link you to resources/newsletters/lang/suffix and then back to resources/newsletters. Is this not how it behaved?

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo

Mmm I did

<?php
echo $_SERVER['PHP_SELF'];
echo $_SERVER['REQUEST_URI'];
?>

and got

/index.php/resources/newsletters
resources/newsletters

I was under the impression that segments get built from the template level which would make sense for the URL that is getting generated.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

right, can you try this:

<?php
global $IN;
print_r($IN->SEGS);
?>

It’s strange, because there’s no reason that I can see that it would redirect back to site/newsletters

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo
Array ( [1] => site [2] => newsletter )

I’ve the following redirects:

# Newsletter Archive # 
RewriteCond %{REQUEST_URI} /resources/newsletter_archive/$
RewriteRule ^.*$ /resources/newsletter_archive/$ [L]
RewriteRule ^resources/newsletter_archive/(.*)$ /index.php/site/newsletter_archive_detail/$1 [L]

# Redirect translation links # 
RewriteRule ^site/news_detail/(.*)$ /resources/newsletters/$1 [R=301,L]
RewriteRule ^site/newsletter/$ /resources/newsletters [R=301,L]

# Newsletters # 
RewriteCond %{REQUEST_URI} /resources/newsletters/$
RewriteRule ^.*$ /resources/newsletters/$ [L]

# Newsletter Categories # 
RewriteRule ^resources/newsletters/subscribe(.*)$ /index.php/site/subscribe/$1 [L]
RewriteRule ^resources/newsletters/category(.*)$ /index.php/site/newsletter_category/$1 [L]

RewriteRule ^resources/newsletters/(.*)$ /index.php/site/news_detail/$1 [L]
       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Ok, I think I see now. Glad to know it’s not the extension pushing all those reloads. Basically I see your redirecting the lang/suffix to site/news_detail with is then redirecting to resources/newsletters. I can’t really say if that’s a good thing, but it does appear to be working so I’d go with it. Really I just wanted to be sure that it wasn’t the extension messing up.

       
George Ornbo's avatar
George Ornbo
272 posts
18 years ago
George Ornbo's avatar George Ornbo

Yes not ideal but is working at the moment.

Thanks again.

       
Brent Cartier's avatar
Brent Cartier
87 posts
18 years ago
Brent Cartier's avatar Brent Cartier

Hi Mark - fantastic extension! I was wondering if there’s an easy way to get this extension to switch category custom fields (for example switch the default cat_name to a new custom field called cat_name_fr).

This would take advantage of the new 1.6 features and would save me from maintaining identical category group structures.

What do you think?

       
First 4 5 6 7 8 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.