8 of 8
8
Simple Translator (formerly known as Another Language Switcher)
Posted: 20 March 2008 04: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 10:04 PM   [ Ignore ]   [ # 128 ]  
Grad Student
Rank
Total Posts:  98
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 08:42 AM   [ Ignore ]   [ # 129 ]  
Grad Student
Avatar
Rank
Total Posts:  46
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 06:35 AM   [ Ignore ]   [ # 130 ]  
Grad Student
Rank
Total Posts:  38
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 11:08 AM   [ Ignore ]   [ # 131 ]  
Grad Student
Rank
Total Posts:  54
Joined  08-06-2007

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

 Signature 

Efraín Bárcena

Profile
 
 
Posted: 08 May 2008 06:17 PM   [ Ignore ]   [ # 132 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  135
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 11:07 PM   [ Ignore ]   [ # 133 ]  
Grad Student
Rank
Total Posts:  54
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

Profile
 
 
Posted: 26 May 2008 11:50 PM   [ Ignore ]   [ # 134 ]  
Grad Student
Rank
Total Posts:  54
Joined  08-06-2007
Chad Crowell - 08 May 2008 06: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

Profile
 
 
Posted: 15 July 2008 06:46 AM   [ Ignore ]   [ # 135 ]  
Grad Student
Avatar
Rank
Total Posts:  87
Joined  07-02-2008
KKCJ - 21 April 2008 06: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 10:16 AM   [ Ignore ]   [ # 136 ]  
Grad Student
Avatar
Rank
Total Posts:  87
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 10:23 AM   [ Ignore ]   [ # 137 ]  
Lab Assistant
RankRank
Total Posts:  186
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 

.be

Profile
 
 
Posted: 17 August 2008 11:16 AM   [ Ignore ]   [ # 138 ]  
Grad Student
Rank
Total Posts:  54
Joined  08-06-2007
bobh - 17 August 2008 10: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

Profile
 
 
Posted: 17 August 2008 12:16 PM   [ Ignore ]   [ # 139 ]  
Lab Assistant
RankRank
Total Posts:  186
Joined  01-20-2006
Efraín Bárcena - 17 August 2008 11: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 

.be

Profile
 
 
Posted: 29 August 2008 09:21 AM   [ Ignore ]   [ # 140 ]  
Grad Student
Avatar
Rank
Total Posts:  73
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
 
 
   
8 of 8
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 10:33 AM
Total Registered Members: 60971 Total Logged-in Users: 30
Total Topics: 73683 Total Anonymous Users: 15
Total Replies: 397485 Total Guests: 471
Total Posts: 471168    
Members ( View Memberlist )