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

Robert Eerhart's avatar
Robert Eerhart
57 posts
18 years ago
Robert Eerhart's avatar Robert Eerhart

Thanks guys… this helped me a lot!

At first it didn’t work, but the right code (for me) must be:

<?php
global $IN;
if ( isset($IN->global_vars['simple_language']) && $IN->global_vars['simple_language'] == 'English' ) {
    echo '<a href="http://{path=">Nederlands</a>';
} else {
    echo '<a href="http://{path=">English</a>';
}
?>

I even can use {if simple_language == "Nederlands"} code {/if}

So i’m happy!

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

Well isn’t that sexy. I’d use the EE conditional to keep it all in the family. Anyway, I’m glad you got it figured out.

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

Nice, I’d drop the PHP code and use this instead:

{if simple_language == "English"}
<a href="http://{path=">Nederlands</a>
{if:else}
<a href="http://{path=">English</a>
{/if}
       
Robert Eerhart's avatar
Robert Eerhart
57 posts
18 years ago
Robert Eerhart's avatar Robert Eerhart

Translation works like a clock!

Only the category names are still an issue.

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

Indeed. Glad the rest of it’s working for you though.

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

Alright, I have it switching categories now. It’s a hack, but I’m pretty pleased with it. You can read about the implementation at the top of the thread, but as a teaser you only need to perform the following:

{exp:weblog:categories weblog="blog" category_group="{exp:translator:category_group="4"}"}…{/exp:weblog:categories}

If category group 4 were named ‘blog’ and there was another category group named ‘blog_ja’ it would switch blog to the suffixed version assuming a user is browsing in japanese.

       
giovanni's avatar
giovanni
203 posts
18 years ago
giovanni's avatar giovanni

w00t! w00t!!

       
Robert Eerhart's avatar
Robert Eerhart
57 posts
18 years ago
Robert Eerhart's avatar Robert Eerhart

Mark, this is working for me! Thanx for the fast solution

Super! Give this man a medal, please!

       
textdriven's avatar
textdriven
107 posts
18 years ago
textdriven's avatar textdriven

Hi Mark,

I get a syntax error…

Error

The following tag has a syntax error:

{exp:language:switcher}

Please correct the syntax in your template.

My template is just this…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Testing</title>        
</head>
<body>

{exp:language:switcher}

{exp:weblog:entries weblog="home_page"}
<h2>{title}</h2>
{body}
{/exp:weblog:entries}

</body>
</html>

I don’t understand what is wrong? Sorry I’m a bit new to EE.

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

Oh geeze, that’s my fault. When I changed the name of the extension I changed the tag to be

{exp:translator:simple}

Sorry, I’ll update the first post to reflect the change also.

       
textdriven's avatar
textdriven
107 posts
18 years ago
textdriven's avatar textdriven

Cheers Mark. I’m glad it was just that, I was worried it was some PHP error.

Thank you for making this great extension!

       
textdriven's avatar
textdriven
107 posts
18 years ago
textdriven's avatar textdriven

It works great. Is it easy/possible add custom fields named something other than “body” or “title”?

Also there are areas of the site that need to change based on the language like the footer and branding. I thought I would make a new section called “snippets” with a text area custom fields for each language. There just do something like this…

<!-- Branding -->
<div id="branding">
{exp:weblog:entries weblog="snippets" entry_id="3"}
{body}
{/exp:weblog:entries}
</div>

…is this the best method for doing this?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
18 years ago
Mark Bowen's avatar Mark Bowen

Hi Mark,

WOW!!! This is an absolutely amazing solution, thanks a lot. We just finished creating a site in two languages and although the method we used in the end was pretty straightforward, this solution is really impressive. Thanks.

Just one thing I did notice though. When you go to Extensions -> Simple Translator -> Settings the instructions tell you to use :

{exp:language:switcher}

as opposed to :

{exp:translator:simple}

which is what it is supposed to be I think?

Sorry if this has already been mentioned. I did read through most of the replies but sometimes do miss a thing or two!! 😊

Once again though, thanks for a simply fantastic extension. Very greatfully received.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
18 years ago
Mark Bowen's avatar Mark Bowen

Hi Mark,

Sorry to be a pain on this again. I was just wondering why you chose to write the tag as :

{exp:translator:simple}

instead of :

PLEASE NOTE THE CODE SHOWN BELOW IS NOT THE CORRECT CODE

{exp:simple:translator}

Just thought that it might be easier to remember in that way as it is the name of the extension?

I could be sleeping whilst writing this though so if there is a reason for it then please don’t feel bad in telling me even if it is blatantly obvious as my head sometimes stops working every now and then and just needs a slight kick-start to get it going again!! 😊

Best wishes,

Mark

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
18 years ago
Ingmar Greil's avatar Ingmar Greil

Actually, this top-down approach is quite common in software, and particular programming. This leaves room for {exp:translator:advanced} or similar, while still showing their common heritage or purpose, as it were.

       
First 2 3 4 5 6 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.