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!
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.
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.
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?
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
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.