8 of 9
8
Simple Translator (formerly known as Another Language Switcher)
Posted: 20 March 2008 03:55 PM   [ Ignore ]   [ # 127 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  120
Joined  02-21-2005

Interesting point. Unfortunately I do not have the solution….sorry

 Signature 

Atelier2

Atelier Voor Beeldhouwwerken

Profile
 
 
Posted: 20 March 2008 09:04 PM   [ Ignore ]   [ # 128 ]  
Lab Assistant
RankRank
Total Posts:  104
Joined  09-19-2006

Very good point…

Mark - how much work would it be to get the extension using a global variable in path.php as described here in the EE Wiki? (like ‘www.mydomain.com/en/group/template’ or ‘www.mydomain.com/fr/group/template’ etc..)  I’ll have a look at the code… but I’ll probably just mangle it tongue laugh

-Brent

Profile
 
 
Posted: 02 April 2008 07:42 AM   [ Ignore ]   [ # 129 ]  
Grad Student
Avatar
Rank
Total Posts:  47
Joined  09-04-2006

Hi,
do you know any incompatibilities with Solspace Tag Module?

Looks like page crashes when the {if simple_language == } is put inside a {exp:tag:related_gallery_entries } declaration…

Carlo

Profile
 
 
Posted: 21 April 2008 05:35 AM   [ Ignore ]   [ # 130 ]  
Grad Student
Rank
Total Posts:  64
Joined  01-14-2008

Mark, I’ve run into a wall. I have custom fields for each weblog, and I’ve adopted a naming scheme of {WEBLOGNAME-body} for my custom fields, since EE requires a unique short name for custom fields, regardless of them being in different field groups.

The problem is when I want to have alternate languages for the {title} field. Normally I’d have custom fields named {title_jp} and be done with it, but since I have to have them named uniquely, and I want to have more than one weblog have alternate language content, Simple Translator obviously doesn’t pick up on the fact that {WEBLOGNAME-title_jp} should be substituted for the {title} field when the language is changed.

The only solution I can think of is to have an “if lang == jp show {WEBLOGNAME-title_jp} else show {title}” conditional in my templates, but it seems rather messy.

Any ideas?

Profile
 
 
Posted: 22 April 2008 10:08 AM   [ Ignore ]   [ # 131 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-06-2007

Thanks for this extension Mark! Is working great for me.

 Signature 

Efraín Bárcena
http://www.eStudio81.net

Profile
 
 
Posted: 08 May 2008 05:17 PM   [ Ignore ]   [ # 132 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  160
Joined  06-24-2007

Re; Categories

If I have 1 weblog with 10 entries and 1 set of categories called Cats and a corresponding set of categories called Cats_de, riddle me this:

1. Do both category groups have to be attached to the weblog in edit_groups? or just the english set of categories?
2. If the answer to #1 is both, do I need to select both the english and german category for each entry in the edit screen?

or does ST just know to show the alternate category list and which cats in the foreign languages that the entries belong to?

Thanks

 Signature 

Web Inception
Websites that work for you.
http://www.webinception.com

Profile
 
 
Posted: 26 May 2008 10:07 PM   [ Ignore ]   [ # 133 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-06-2007

Hey Mark,

Is there a way to be able to translate weblog entries - variable pairs when using the suffix in the category group names (category / category_es) and not on the weblog names????

I need to use the following code and its displays the two languages:

{exp:weblog:entries weblog="weblog_name"}

{categories}

<h2>{category_name}</h2>

{/categories}

 Signature 

Efraín Bárcena
http://www.eStudio81.net

Profile
 
 
Posted: 26 May 2008 10:50 PM   [ Ignore ]   [ # 134 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-06-2007
Chad Crowell - 08 May 2008 05:17 PM

Re; Categories

If I have 1 weblog with 10 entries and 1 set of categories called Cats and a corresponding set of categories called Cats_de, riddle me this:

1. Do both category groups have to be attached to the weblog in edit_groups? or just the english set of categories?
2. If the answer to #1 is both, do I need to select both the english and german category for each entry in the edit screen?

or does ST just know to show the alternate category list and which cats in the foreign languages that the entries belong to?

Thanks

Hey Chad,

Yes both category groups have to be attached to that one weblog and yes you need to select both, the English and German categories for each entry.

 Signature 

Efraín Bárcena
http://www.eStudio81.net

Profile
 
 
Posted: 15 July 2008 05:46 AM   [ Ignore ]   [ # 135 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  111
Joined  07-02-2008
KKCJ - 21 April 2008 05:35 AM

Mark, I’ve run into a wall. I have custom fields for each weblog, and I’ve adopted a naming scheme of {WEBLOGNAME-body} for my custom fields, since EE requires a unique short name for custom fields, regardless of them being in different field groups.

The problem is when I want to have alternate languages for the {title} field. Normally I’d have custom fields named {title_jp} and be done with it, but since I have to have them named uniquely, and I want to have more than one weblog have alternate language content, Simple Translator obviously doesn’t pick up on the fact that {WEBLOGNAME-title_jp} should be substituted for the {title} field when the language is changed.

The only solution I can think of is to have an “if lang == jp show {WEBLOGNAME-title_jp} else show {title}” conditional in my templates, but it seems rather messy.

Any ideas?

Yes.  I also have this problem. I need to be able to translate the title of each entry and you can’t have more than one title_{LANG} custom field.  Appending a WEBLOGNAME to each custom field will work for everything except title.

Any suggestions?

Matt @ View Creative

 Signature 

View Creative Agency | http://www.viewcreative.co.uk

Profile
 
 
Posted: 15 July 2008 09:16 AM   [ Ignore ]   [ # 136 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  111
Joined  07-02-2008

Also is there a simple way to set the xml:lang & lang ?

e.g.


<html;xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en-gb” lang=“en-gb”>

I’ve had to modify the extension to define a “simple_language_suffix”

 Signature 

View Creative Agency | http://www.viewcreative.co.uk

Profile
 
 
Posted: 17 August 2008 09:23 AM   [ Ignore ]   [ # 137 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  226
Joined  01-20-2006

one more question: is there a way to exclude the current language from the link list? To me there is no need to show a link to switch to english if the page is already in english.

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
Posted: 17 August 2008 10:16 AM   [ Ignore ]   [ # 138 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-06-2007
bobh - 17 August 2008 09:23 AM

one more question: is there a way to exclude the current language from the link list? To me there is no need to show a link to switch to english if the page is already in english.

You can use something like this:

{if simple_language == "Spanish"}<a href="index.php/lang/default/">English</a>
{if:else}<a href="index.php/lang/_es/">Español</a>{/if}

My path looks weird but it actually worked for me.

 Signature 

Efraín Bárcena
http://www.eStudio81.net

Profile
 
 
Posted: 17 August 2008 11:16 AM   [ Ignore ]   [ # 139 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  226
Joined  01-20-2006
Efraín Bárcena - 17 August 2008 10:16 AM

You can use something like this:

{if simple_language == "Spanish"}<a href="index.php/lang/default/">English</a>
{if:else}<a href="index.php/lang/_es/">Español</a>{/if}

My path looks weird but it actually worked for me.

works great Efraín, thanks.

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
Posted: 29 August 2008 08:21 AM   [ Ignore ]   [ # 140 ]  
Grad Student
Avatar
Rank
Total Posts:  78
Joined  03-17-2006

Love this extension! Just wanted to change one thing: instead of an unordered list, I wanted a dropdown menu. I made a little hack to my copy which seems to do the trick. Don’t like messing with mods, but thought this might be useful for some. Hope that’s okay Mark!

Paste the following over lines 189-374 of ext.simple_translator.php.

$r = ‘<form action=”” name=“langmenu” method=“post”><select name=“langsel”><option selected value=”“>Change language…</option>’;
     
      //  =============================================
      //  Error Prevention
      //  =============================================
      //  We want to make sure that there is always
      //  a languages element of the settings array
      // ——————————————————————-
      if(!isset($this->settings[‘languages’]))
      {
        $this->settings[‘languages’] = ‘’;
      }
     
      //  =============================================
      //  Find the HREF
      //  =============================================
      //  We’ll parse out the base href, because I
      //  don’t know of any better way to do this.
      // ——————————————————————-
      $base = preg_replace(’/\/$/’, ‘’, $PREFS->core_ini[‘site_url’]).’/’;
      if($PREFS->core_ini[‘site_index’] != ‘’) $base.= $PREFS->core_ini[‘site_index’];
      if($PREFS->core_ini[‘force_query_string’] == ‘y’) $base.= ‘?’;
      $base = preg_replace(’/\/$/’, ‘’, $base).’/’;
     
      //  =============================================
      //  Add SEGS to the HREF
      //  =============================================
      //  We’ll add all the segs up to, but not
      //  including the language segments
      // ——————————————————————-
      $segs = array();
      foreach($IN->SEGS as $k=>$s)
      {
        if($s == ‘lang’ && $k == count($IN->SEGS)-1) break;
        $segs[] = $s;
      }
      $base.= implode(’/’, $segs);
      $base.= (count($segs) > 0)?’/’:’‘;
     
      //  =============================================
      //  Set Cookie
      //  =============================================
      //  If we are looking at a new language from the
      //  url we’ll set the new cookie and redirect to
      //  the lang’less url
      // ——————————————————————-
      if(@$IN->SEGS[count($IN->SEGS)-1] == ‘lang’)
      {
        $value = $IN->SEGS[count($IN->SEGS)];
        if($value == ‘default’) $value = false;
        $FNS->set_cookie($this->cookie_name, $value, 60*60*24*7);
       
        header(‘Location: ‘.$base);
        exit;
      }
     
      //  =============================================
      //  Get Category Groups, Weblogs & Vars
      //  =============================================
      //  We’ll get these so we can switch them too!
      // ——————————————————————-
      if(!is_array($sess->cache)) $sess->cache = array();
     
      if(!isset($sess->cache[‘mh_table_category_groups’]))
      {
        $sess->cache[‘mh_table_category_groups’] = array();
        $cat_groups_q = $DB->query(‘SELECT * FROM exp_category_groups’);
        foreach($cat_groups_q->result as $group)
        {
          $sess->cache[‘mh_table_category_groups’][$group[‘group_name’]] = $group;
        }
      }
     
      if(!isset($sess->cache[‘mh_table_weblogs’]))
      {
        $sess->cache[‘mh_table_weblogs’] = array();
        $weblogs_q = $DB->query(‘SELECT * FROM exp_weblogs’);
        foreach($weblogs_q->result as $weblog)
        {
          $sess->cache[‘mh_table_weblogs’][$weblog[‘blog_name’]] = $weblog;
        }
      }
     
      if(!isset($sess->cache[‘mh_table_global_variables’]))
      {
        $sess->cache[‘mh_table_global_variables’] = array();
        $vars_q = $DB->query(‘SELECT * FROM exp_global_variables WHERE user_blog_id=”’.((!defined(‘UB_BLOG_ID’))?0:UB_BLOG_ID).’”’);
        foreach($vars_q->result as $var)
        {
          $sess->cache[‘mh_table_global_variables’][$var[‘variable_name’]] = $var[‘variable_data’];
        }
      }
     
      //  =============================================
      //  Get the List
      //  =============================================
      //  We’ll parse through our available languages
      //  and create a list.
      //  We’ll also set our category and weblog
      //  switches here.
      // ——————————————————————-
      $languages = array_filter(preg_split(’/[\r\n]+/’, $this->settings[‘languages’]));
      foreach($languages as $k=>$l)
      {
        $tmp = array_filter(preg_split(’/:/’, $l));
        if($k == 0)
        {
          $tmp[0] = ‘default’;
          $tmp[1] = $l;
        }
        if(count($tmp) == 1)
        {
          $tmp[1] = $tmp[0];
        }
       
        //  =============================================
        //  Check Selected Language
        //  =============================================
        //  Here we’ll class the selected language in the
        //  list and then set up other translations.
        // ——————————————————————-
        $class = array();
        if((isset($_COOKIE[$this->c_cookie_name]) && $_COOKIE[$this->c_cookie_name] == $tmp[0]) || (!isset($_COOKIE[$this->c_cookie_name]) && $tmp[0] == ‘default’))
        {
          $class[] = ‘selected’;
          $IN->global_vars[‘simple_lan

Profile
 
 
Posted: 17 September 2008 01:32 PM   [ Ignore ]   [ # 141 ]  
Grad Student
Rank
Total Posts:  69
Joined  12-14-2007

Hi

Can someone advise on how to use the simple translator with the pages module…is it possible??

Cheers

Profile
 
 
Posted: 18 September 2008 01:03 PM   [ Ignore ]   [ # 142 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  118
Joined  11-02-2005

pls. allow a few questions for mark huot:

1. are you still using and developing this extension?

2. will changing the url_title work and how does google cope with the double language content?

3. will this extension hold in ee 2.0?

3. which is - in your experience - the best ee multi-lang approach?

thank you!

 Signature 

thomaswinterstetter.com
1.6.x Build: latest

Profile
 
 
Posted: 26 September 2008 10:21 PM   [ Ignore ]   [ # 143 ]  
Grad Student
Avatar
Rank
Total Posts:  56
Joined  08-06-2007
Cocoaholic - 11 May 2007 06:32 AM

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

{if simple_language == "English"}
<a href="{path=">Nederlands</a>
{if:else}
<a href="{path=">English</a>
{/if}

Hey Cocoaholic,

How is this working for you?? I try using your method on an embedded template but only works on the home/index page. Lets say I’m on the “About” page and I use this… it takes me back to the home page.

This code actually worked for me on every page:

{if simple_language == "Spanish"}
<a href="index.php/lang/default/">English</a>
{if:else}
<a href="index.php/lang/_es/">Español</a>
{/if}

The problem with this is that it generates an extra index.php every time the language gets switched. Like this:

http://mysite.com/index.php/about/index.php/index.php/index.php/

It does the job since it takes me to the right page in the right language but that doesn’t look right.

Is there another variable other than {path=“site_index”} than could be used so it recognized the location where the switcher is used? or do you have any ideas why your method isn’t working for me?

Thanks

 Signature 

Efraín Bárcena
http://www.eStudio81.net

Profile
 
 
Posted: 27 October 2008 01:38 PM   [ Ignore ]   [ # 144 ]  
Grad Student
Avatar
Rank
Total Posts:  39
Joined  07-31-2008

I am a little lost here, because I am trying to translate the “blog” section of my website, so basically I created a similar category group adding “_fr_ extension to it,
and then creating similar custom fields, but in french. (so I have 2 category groups the english one “3” the french “4”)

now i wanted the english to be default and then change it to french, so I add:

category_group=”{exp:translator:simple category_group=“3”}”

to my categories tags, when I switch languages I everything changes, except the categories…Is there is something I am missing here,I will be very glad if you take your time to answer me.

this is my actual code.


{exp:weblog:category_heading weblog=”{my_weblog}” category_group=”{exp:translator:simple category_group=“3”}”}
              <h3 class=“company_titles”>{category_name}</h3>
              {if category_description}
                {category_description}
              {/if}
             
          {/exp:weblog:category_heading}

I ve added {exp:transl…} as specified in the information that comes with the extension.


I will like to translate the category title and content, but I am not sure where to add the “simple translator” code on this. I created 2 categories groups weblog and weblog_fr
so I will like to be able to switch between both, THANKS for any help on this!

 Signature 

el pobre no es el que tiene poco sino el que desea más…

Profile
 
 
   
8 of 9
8
 
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: 64920 Total Logged-in Users: 39
Total Topics: 81877 Total Anonymous Users: 25
Total Replies: 440163 Total Guests: 221
Total Posts: 522040    
Members ( View Memberlist )