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
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.
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?
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:
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.
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.
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.
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.
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.
// =============================================
// 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
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.
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?
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.
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!