MyBB Community Forums

Full Version: Foregin translate (0.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi i have found that plugins 1.6* version i manualy change for 1.8* and i try to install in acp everytime i have a white page is dont want enabled i have try + 10 time .. Any know the problem ?


there is the code (only 1 file)

<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('global_start', 'foreigntranslate_global');

function foreigntranslate_info()
{
return array(
"name" => "Foregin translate",
"description" => "Plugin shows a Google Trasnale bar for people who do not live in your country.  <br /><span style=\"font-size:8px;\">If plugin does not want to activate, try activating it a few more times.</span>",
"website" => "",
"author" => "Watt",
"authorsite" => "",
"version" => "0.1",
"guid" => "61f572f4853391d103ac408c775c7e3f",
"compatibility" => "18*",
);
}

function foreigntranslate_activate() 
{
global $db, $mybb;
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
$is_installed = 0;

$query = $db->query("SELECT * FROM `".TABLE_PREFIX."settinggroups` WHERE name = \"foreigntranslate\" LIMIT 1;"); 
while($fet = $db->fetch_array($query))
{
$is_installed = 1; // additional check
}

if($is_installed == 0){
$foreigntranslate_group = array(
"gid" => "NULL",
"name" => "foreigntranslate",
"title" => "Foregin translate Configuration",
"description" => "Plugin shows a Google Trasnale bar for people who do not live in your country.",
"disporder" => "0",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $foreigntranslate_group); 
$gid = $db->insert_id();

$foreigntranslate_config[] = array(
"sid" => "NULL",
"name" => "foreigntranslate_onoff",
"title" => "Turn on/off",
"description" => "Turn plugin on/off",
"optionscode" => "yesno",
"value" => "1",
"disporder" => 1,
"gid" => intval($gid),
); 
$foreigntranslate_config[] = array(
"sid" => "NULL",
"name" => "foreigntranslate_lang",
"title" => "Your language tag",
"description" => 'Select your language tag from <a target="_blank" href="http://pgc-play.pl/languageable.html">this list - click</a> and rewrite it.',
"optionscode" => "text",
"value" => "en",
"disporder" => 2,
"gid" => intval($gid),
); 

foreach($foreigntranslate_config as $sacfg)
{
$db->insert_query("settings", $sacfg);
}

find_replace_templatesets("headerinclude", '#{\$stylesheets}#', "{\$stylesheets}{\$foreigntranslate}");
find_replace_templatesets("footer", '#\<\!\-\- End powered by \-\-\>#', "<!-- End powered by -->{\$foreigntranslate_footer}"); 
}
rebuildsettings();
}

function foreigntranslate_deactivate()
{
global $db, $mybb;
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";

$db->delete_query("settings","name LIKE 'foreigntranslate_%'");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='foreigntranslate'");
rebuildsettings();
find_replace_templatesets("headerinclude", '#'.preg_quote('{$foreigntranslate}').'#', '',0);
find_replace_templatesets("footer", '#'.preg_quote('{$foreigntranslate_footer}').'#', '',0);
}

function foreigntranslate_global()
{
global $db, $mybb, $templates, $foreigntranslate, $foreigntranslate_footer;

if(!$mybb->settings['foreigntranslate_onoff'] OR $mybb->settings['foreigntranslate_onoff'] == "off") // if off
return false;

if (substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2) != substr($mybb->settings['foreigntranslate_lang'],0,2))
$foreigntranslate = '<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script><script>function googleTranslateElementInit() {  new google.translate.TranslateElement({    pageLanguage: \''.$mybb->settings['foreigntranslate_lang'].'\',    layout: google.translate.TranslateElement.InlineLayout.SIMPLE  }, \'google_translate_element\');}</script>';
else
$foreigntranslate = '';
$list = array('Serwery CS', 'Multigaming', 'Counter Strike', 'Games support', 'CS Servers');

$foreigntranslate_footer = 'Translation plugin by <a href="" title="'.$list[rand(0,3)].'"></a>.';
}

?>
for white page errors,
recent entries of server error log should be checked to trace the cause.
in general, web host control panel should be having link to the error log
(2020-08-05, 12:31 PM).m. Wrote: [ -> ]for white page errors,
recent entries of server error log should be checked to trace the cause.
in general, web host control panel should be having link to the error log

i go see if i can see an error and I have check in mybb error.log Finnaly enabled for the moment the last error of i see is for a plugins named safelinks but I cannot enabled the plugins translate because like explained is made a white page and Not activated

my Server dont made Log 0 byte on the file probably because is disabled in the server config for the moment..

Is possible to Add a translate button on the page if that plugins not working maybe i can use only the Google button translate script ?


script found on that link
https://www.w3schools.com/howto/howto_go...nslate.asp
<!DOCTYPE html>
<html lang="en-US">
<body>

<div id="google_translate_element"></div>

<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>

<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<p>This example displays a vertical translate button.</p>

</body>
</html>
well, you can add below code at the bottom of header template of your theme
<div id="google_translate_element"></div>

<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>

<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
(2020-08-05, 12:57 PM).m. Wrote: [ -> ]well, you can add below code at the bottom of header template of your theme
<div id="google_translate_element"></div>

<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>

<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>


thanks you working Do you think is possible to Add other Translation button like Without javascript like that

http://www.webestools.com/translator-but...lator.html

or if you know one better
^ no, javascript is required for the translation functionality.