6 of 9
6
Simple Translator (formerly known as Another Language Switcher)
Posted: 05 July 2007 07:47 AM   [ Ignore ]   [ # 91 ]  
Lab Assistant
RankRank
Total Posts:  104
Joined  09-19-2006

Hi Mark,

Any progress adding category custom fields? I think this existing plugin with that one last feature added will finally be the last piece in the multi-language puzzle.

I’m starting a new project soon and I’ll need to decide which approach to use…

No rush though… grin

Thanks a million!

Profile
 
 
Posted: 10 August 2007 03:48 AM   [ Ignore ]   [ # 92 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

I’ve basically got Simple Translator working, great stuff.  However, I need to add an id attribute to each list item (for styling purposes).

Example:

<ul class="simple-translator">
<
li id="English" class="selected first"><a href="" title="English">English</a></li>
<
li id="German"><a href="" title="German">German</a></li>
<
li id="Dutch"><a href="" title="Dutch">Dutch</a></li>
<
li id="French"><a href="" title="French">French</a></li>
<
li id="Italian" class="last"><a href="" title="Italian">Italian</a></li>
</
ul>

I’d be happy with a class attribute instead, of course.

How can I adapt the extension to add these attributes automatically?  I’ve had a look in the extension file itself but don’t see any reference to an unordered list at all.

Thanks!

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 10 August 2007 04:33 AM   [ Ignore ]   [ # 93 ]  
Lab Assistant
RankRank
Total Posts:  104
Joined  09-19-2006

Hi lithiumdave,

You could always create the list in you templates like so:

<ul class="simple-translator">
   
     <
li id="English" {if simple_language == "English"}class="selected first"{/if}>
        <
a href="/lang/default/" title="English">English</a>
     </
li>

   
      <
li id="French" {if simple_language == "French"}class="selected first"{/if}>
          <
a href="/lang/_fr/" title="French">French</a>
      </
li>

       
etc...
</
ul>

Profile
 
 
Posted: 10 August 2007 04:47 AM   [ Ignore ]   [ # 94 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

Now that works really well!  Almost…

The only bit I’m struggling with now is the path.  For example, a href=”/lang/_de/” finds the root of the site, so I get a 404.  The path needs to basically append /lang/_de/ (I think!) to the end of whatever the URL happens to be, in the way that the extension does. 

Is there a way of achieving this with a hard-coded path, as in your example?

Many thanks for your help so far smile

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 10 August 2007 06:52 AM   [ Ignore ]   [ # 95 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

I’ve done it like this anyway:

<?php
  $domain
= $_SERVER['HTTP_HOST'];
  
$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
?>

<ul class="simple-translator">
     <
li id="English" {if simple_language == "English"}class="selected first"{/if}>
        <
a href="<?php echo $url2; ?>lang/default/" title="English">English</a>
     </
li>
      <
li id="German" {if simple_language == "German"}class="selected"{/if}>
          <
a href="<?php echo $url2; ?>lang/_de/" title="German">German</a>
      </
li>
     <
li id="Dutch" {if simple_language == "Dutch"}class="selected"{/if}>
          <
a href="<?php echo $url2; ?>lang/_nl/" title="Dutch">Dutch</a>
      </
li>
     <
li id="French" {if simple_language == "French"}class="selected"{/if}>
          <
a href="<?php echo $url2; ?>lang/_fr/" title="French">French</a>
      </
li>
     <
li id="Italian" {if simple_language == "Italian"}class="selected"{/if}>
          <
a href="<?php echo $url2; ?>lang/_it/" title="Italian">Italian</a>
      </
li>
</
ul>

It seems to be working ok so far at least.  Be interested to learn if there’s a non-PHP way to tackle it.

Cheers.

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 10 August 2007 01:50 PM   [ Ignore ]   [ # 96 ]  
Lab Assistant
RankRank
Total Posts:  104
Joined  09-19-2006

Sorry lithiumdave, I put in a leading slash by mistake! the links should be a href=“lang/_fr/” (relative) instead of “/lang/_fr” (absolute). That way it adds it to the end of the current url without having to do all the php business.

Let me know if that works for you.

Profile
 
 
Posted: 11 August 2007 02:50 AM   [ Ignore ]   [ # 97 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

What on earth am I playing at?!  I can’t believe I actually started messing about with PHP there, so obvious!  In my defence, it was the end of a very, very long day (week, actually).

I’ve brought shame on myself and my family….  ; )

Heh heh.  Thanks bcartier!

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 13 August 2007 11:35 AM   [ Ignore ]   [ # 98 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

As I thought, I’m here again…

The client has now decided that they want category names to also language switch too, even though they insisted they wouldn’t need that when I began.

I’m struggling with implementing category language switching and would appreciate some help, rather urgently in fact!

I have the following code in my templates to output the list of categories, as well as also display the list of entries within each category.  Further, there are conditionals in there too to conditionally display entries only if you’re actually viewing that category.

I’ll simplify it next, but just wanted to show what I’ve actually got in there first:

<ul class="sidenav">
{exp:weblog:categories weblog="products" style="linear"}
                
<li {if "{segment_2}" == "C{category_id}" OR "{segment_3}" == "{category_id}"}class="subcurrent"{/if}><a href="{path=products}">{category_name}</a>
{if "{segment_2}" == "C{category_id}" OR "{segment_3}" == "{embed:cat}"}
<ul>
{exp:weblog:entries weblog="products" category="{category_id}" dynamic="off"}
{if
"{embed:current}" != "{url_title}"}<li><a href="{homepage}products/{url_title}/{category_id}/">{title}</a></li>{/if}
{if
"{embed:current}" == "{url_title}"}<li><span>{title}</span>{/if}
{
/exp:weblog:entries}
</ul>
{/if}
</li>
{/exp:weblog:categories}
            
</ul>

I suppose broken down to brass tacks it’s simply this:

{exp:weblog:categories weblog="products" style="linear"}
                
<li><a href="{path=products}">{category_name}</a>
<
ul>
{exp:weblog:entries weblog="products" category="{category_id}" dynamic="off"}
<li><a href="{homepage}products/{url_title}">{title}</a></li>
{/exp:weblog:entries}
</ul>
</
li>
{/exp:weblog:categories}

Now, following Mark’s instructions I’ve done the following to the above:

{exp:weblog:categories weblog="products" style="linear"
category_group="{exp:translator:simple category_group="2"}"}

as the category group is 2. The category name is ‘Products’.

I’ve now created a new category group called ‘Products_fr’ (which has a group id of 3).  However, when I switch languages (to French, using a _fr suffix) no categories whatsoever are output to the page.

I think I might be able to see why, but I just cannot figure out the solution.

Any help very very much appreciated : )

Dave

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 13 August 2007 11:46 AM   [ Ignore ]   [ # 99 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1184
Joined  01-05-2006

lithiumdave—is there any way you can place an {exp:weblog:entries /} tag onto the page and make sure that normal custom fields are switching?  Thanks.  Also, can you turn on template debugging and try to find the call to the weblog:categories method?  Are there any attributes associated with it?  If possible can you PM me a txt file of your template debugger?

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 13 August 2007 12:52 PM   [ Ignore ]   [ # 100 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

Thanks for the quick reply Mark, really appreciate it.

I can confirm that normal custom fields are switching no problem, I have it set up here:

http://hotbox.bluestormtests.co.uk and http://hotbox.bluestormtests.co.uk/products/hotbox-heater/4/ are perfect working examples.

You can see the category switching not working on this page:

http://hotbox.bluestormtests.co.uk/products/hotbox-heater/4/ (click the 2nd from right flag, French, at the top of the page - I only have a French category group set up so far, Products_fr)

I’ll PM you the debugging output from that template, and also login details to the CP.

Thank you SO MUCH for your help Mark, you’re a legend.

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 13 August 2007 02:44 PM   [ Ignore ]   [ # 101 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

Hi Mark,

I’ve PM’d you but my PM sent messages folder is reporting being empty, which is odd.  Anyway, just to let u know I’ve sent the PM. Let me know if u got it smile

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 13 August 2007 02:49 PM   [ Ignore ]   [ # 102 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1184
Joined  01-05-2006

lithiumdave — I just looked over your debugging and it seems that the category is switching, from 2 to 3.  Can you try hardcoding 3 as a category?  Does it work then?

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 13 August 2007 03:04 PM   [ Ignore ]   [ # 103 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  09-16-2004

It’s odd - I’ve put category_group=“2” and categories get output just fine.  Any other number - no joy.  I’ve tried category_group=“3” but…

Ah, wait… I need to assign my new language-based category groups to the Products weblog in Admin too don’t I?  Doh!

Right… once I do that then the correct categories do display!

However, the category links are now incorrect, so when I click any categories they’re going to a blank page.

But then I need to go into each entry again and assign each product to each of the new language-based categories don’t I??

If all my presumption are correct then (a) I am indeed an idiot and (b) my issue is solved and (c) you’re a very very patient man, thank you for your time smile

Dave

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 13 August 2007 03:26 PM   [ Ignore ]   [ # 104 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1184
Joined  01-05-2006

@lithiumdave — i’d say you have it.  your reasoning sounds fine to me.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 13 August 2007 03:46 PM   [ Ignore ]   [ # 105 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15380
Joined  05-15-2004
lithiumdave - 13 August 2007 02:44 PM

I’ve PM’d you but my PM sent messages folder is reporting being empty, which is odd.

Not at all. The default is not to store outgoing messages.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 21 September 2007 11:22 AM   [ Ignore ]   [ # 106 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-13-2007

Thanks Mark for this extension.

Anybody know of a way to retain caching abilities even when using the Simple Translator?

I just found out (and it’s logical) that the language switch is not possible on the templates where I had enabled the cache.

?

thanks

Profile
 
 
Posted: 21 September 2007 02:45 PM   [ Ignore ]   [ # 107 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1184
Joined  01-05-2006

Anybody know of a way to retain caching abilities even when using the Simple Translator?

I do not know of any way around this, at this time.  I’m thinking there may be some way around this by inserting hidden segments into EE, without the front end user knowing.  That’s where I would start looking.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2007 03:20 PM   [ Ignore ]   [ # 108 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-13-2007

Far from having any idea on how to implement this, but would’nt there be a way to have some control over the cached files?

Activate the cache for every template you like and Simple Translator adds one cache file per language and directs the user to these files.

Just throwing stuff around…

Profile
 
 
   
6 of 9
6
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64944 Total Logged-in Users: 63
Total Topics: 81920 Total Anonymous Users: 39
Total Replies: 440347 Total Guests: 272
Total Posts: 522267    
Members ( View Memberlist )