balazs-endresz / jquery-translate

Automatically exported from code.google.com/p/jquery-translate
5 stars 5 forks source link

Tiny MCE Issues #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

When using the jquery-translate TinyMCE fails to load no idea why.
Also it does not work on IE7.

What version of the product are you using? On what operating system?

I'm running version 1.2.4 on a linux server.

can anyone shed any light on this?

Original issue reported on code.google.com by nuttycod...@gmail.com on 6 Dec 2008 at 1:48

GoogleCodeExporter commented 9 years ago
here's the js am using:
<script type="text/javascript" src="assets/includes/js/jquery.js"></script>
<script type="text/javascript"
src="assets/includes/js/jquery.translate-1.2.4.js"></script>
$(document).ready(function(){
    //translate
    $('body').translate('<?php echo $_SESSION['sellang'];?>');  
});

the session stores the current language to be loaded.

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 1:52

GoogleCodeExporter commented 9 years ago
Could you please send a link to the page?
Also, running it on localhost can cause problems.

Original comment by balazs.endresz on 6 Dec 2008 at 1:57

GoogleCodeExporter commented 9 years ago
Here's the site I'am using it on http://www.surrectmedia.com/ its on a live 
server
rsther then a localhost.

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 2:14

GoogleCodeExporter commented 9 years ago
There seems to be a problem in IE, it only works if you run it afterwards:

javascript:$('body').translate('dutch');void(0);

I'm gonna look into it tomorrow.

I don't see TinyMCE anywhere, where should it be?

Original comment by balazs.endresz on 6 Dec 2008 at 4:15

GoogleCodeExporter commented 9 years ago
sorry the tinyMCE is in the admin so you won't actually see it, I've put an 
instance
on the contact form http://www.surrectmedia.com/contact-us strange thing is it 
works
on the contact form but from some of the admin pages it does not it's very 
strange it
calls the same javascript file for all instances so it should work ever where 
or no
where.

Thanks for your help with this.

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 4:54

GoogleCodeExporter commented 9 years ago
This was so strange that I gave up my plans (and beers) for tonight. And after
struggling for more than an hour finally I've found that f*ckin bug that caused 
IE to
fail. Right at the top you have to change
o.to=T.fn.toLanguageCode(o.to || to) || '';
to
o.to=to;

The first line was added not long ago and it converts the language to language 
code
(like: 'English'->'en'). The problem is that it is called before the api is 
loaded so
it returns undefined (and won't throw an error because a shorter variable is 
declared
as an alias for google.language.Languages before the api is loaded, even it has 
a
value undefined the for-in loop runs without error on it, great). But it almost 
never
came up in Firefox as it loaded the api much faster. This is just a quick fix, 
I have
to put that check inside the translateInit function, a bit testing and it will 
be up
until tomorrow.

I don't know what to say about TinyMCE right now.

Original comment by balazs.endresz on 6 Dec 2008 at 8:02

GoogleCodeExporter commented 9 years ago
Thanks for all your hard work on this,

I've added the changes to the translate file here is the top section:

;(function($){

function $fn(){}
function isSet(a){  return typeof a!='undefined'; }
function isString(a){ return typeof a=='string'; }
function same(a, b){ return a.toLowerCase() == b.toLowerCase(); }

function isInput(e){
    if(!$.nodeName(e[0],'input'))
        return false;
    return e.attr('type').match(/text|button|submit/i);
}

function args(a, b, c, method){
    var from='', to, o={};
    if(typeof a=='object'){o=a;}else{
        if(!b && !c) to=a;
        if(!c && b){ if(typeof b=='object'){ to=a; o=b; }else{ from=a; to=b; } }
        if(a && b && c){ from=a; to=b; o=c;}
        //o.from=T.fn.toLanguageCode(from)||''; o.to=T.fn.toLanguageCode(to)||'';
        o.from=T.fn.toLanguageCode(o.from || from) || '';
        //o.to=T.fn.toLanguageCode(o.to || to) || '';
        o.to=to;

    }
I commented out the line to change and put in the new line only now it does not 
work
at all, have I edited the right place?

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 8:55

GoogleCodeExporter commented 9 years ago
I've fixed the IE issue, now you can download the newer version.
If you could share a non-working page with TinyMCE I'd have a look at it!

Original comment by balazs.endresz on 6 Dec 2008 at 9:02

GoogleCodeExporter commented 9 years ago
downloaded the new file works great in IE7 now thanks a lot I owe you one.
I've created a page with a tinyMCE instance on it that page as no action 
associated
with it so do as you see fit. 

http://www.surrectmedia.com/testpage

The editor works when I comment out 
$('body').translate('<?php echo $_SESSION['sellang'];?>');
but as soon as I enable it the editor fails to load.

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 9:26

GoogleCodeExporter commented 9 years ago
Put the "Content" string inside a label or some tag because the plugin will 
translate
the innerhtml of the containing paragraph in this case if it has a child 
textnode, so
the whole stuff regarding the editor will be translated and replaced too. I 
think
this was the difference between the contact page and this :)

And it's not that important but maybe you shouldn't translate the "mceEditor" 
class,
I don't see any text in it and it will be a bit faster if you tell the plugin 
to skip it:
$('body').translate('english',{not:'.mceEditor'})

Original comment by balazs.endresz on 6 Dec 2008 at 10:15

GoogleCodeExporter commented 9 years ago
yeah you were right I put the content string in span tags and that fixed it the
editor loads up fine now. Good point about the translating the editor class I 
read
somewhere about not translating some parts just could remember where.

The not: is very useful I've got it set so the languages in the drop down never
changes, I tried doing this yesterday but couldn't get it to work.

Thanks for your help you've been amazing!

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 10:51

GoogleCodeExporter commented 9 years ago
Just wondering if google translate languages are updated will the plugin need 
to be
updated as well as I've noticed some languages don't seem to translate I assume 
this
is down to google translate api with it being so new.

Original comment by nuttycod...@gmail.com on 6 Dec 2008 at 11:53

GoogleCodeExporter commented 9 years ago
http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameAr
ray
These are just the languages google recognizes but can't translate all of them, 
the
google.language.isTranslatable(lngCode) function tells if one can be 
translated. But
you can get all the translatable languages with 
$.translate().getLanguages(true). So
you don't have to update the plugin at all. Also there's a bit more convenient
$.translate().isTranslatable method that automatically converts the argument to
language code: http://code.google.com/p/jquery-translate/wiki/General 

And you can also generate a dropdown by just calling
$.translate().ui('select', 'option');
see the Extensions page for details.

Glad I could help and thanks for the bug report!

Original comment by balazs.endresz on 7 Dec 2008 at 11:31