21489 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 7370 Views |
-
Google translate

12 April 2010 at 9:45pm
I have tried to get the google translate to work with SS, but something strange happens.
In IE the google translate is showing, but when you choose a language all the font styles change to the browsers default style.
And in FireFox, I only get a javascript error in firebug that says: "An invalid or illegal string was specified" code: "12
(function(){function g(a){throw a;}var...ion qa(a,b){return a.currentTarget=b} "Have no clue how to fix this, and can't find any help anywhere about this problem.
I have tried adding the google translate into a html page without SS and it works just fine there, but not in SS.Anyone have a clue as to why its not working in Silverstripe?
-
Re: Google translate

24 October 2010 at 8:42pm Last edited: 24 October 2010 9:35pm
Hi, I have the same problem... any clues?
Requirements::customScript(<<<JS
alert("hi there");
JS
);Requirements::customScript(<<<JS
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'pl',
includedLanguages: 'en,cs,fr,de,sk,uk',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
JS
);Requirements::javascript("//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");
I'm adding that alert() function works properly :/
-
Re: Google translate

24 October 2010 at 9:59pm
I noticed that if I add:
Requirements::javascript("//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");
silverstripe won't add this file to the html code,
but if I add:
Requirements::javascript("http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");
silverstipe is adding it to html but in this form script does not work - I checked it on other pages ...
it must begin with "//" -
Re: Google translate

25 October 2010 at 12:55am
Silverstripe won't add the file because if it does not contain http it will assume its a local file and if it can't find it, it will not include the file.
I never used this script, but I can't imagine you have to use //scriptfile to include an external file.
Maybe a bummer, but make sure you read some docs about the api. There are some examples on the web and as far as I can see you need a Google API key as well to use the translate script.
-
Re: Google translate

25 October 2010 at 1:42am Last edited: 25 October 2010 10:04am
there's a code on the http://translate.google.com/translate_tools
that simply adds nice button to translate page. It works well on other pages. Is there a way to overwrite Requirements::javascript() function that allows me to include "//.." files. Where I can find this function - I dom't know Sapphire Framework.<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'pl'
}, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> -
Re: Google translate

27 October 2010 at 7:45am
Is there a way to overwrite Requirements::javascript() function that allows me to include "//.." files.
Where I can find this function? - I don't know Sapphire Framework.
| 7370 Views | ||
|
Page:
1
|
Go to Top |



