PHP code example of charlemagne / shuwa

1. Go to this page and download the library: Download charlemagne/shuwa library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

charlemagne / shuwa example snippets




use charlemagne\Shuwa\Shuwa; 

// will auto detect the source language and define the target language as 'en'
$shuwa = new Shuwa(); 
// will auto detect the source language and define the target language as TARGET
$shuwa = new Shuwa(TARGET);
// replace SOURCE & TARGET with your source language and target language code  
$shuwa = new Shuwa(TARGET, SOURCE);

    // return the source language code
    $shuwa->getSourceLang(); 
    // return the target language code
    $shuwa->getTargetLang(); 
    // set the source language code
    $shuwa->setSourceLang('en'); 
    // set the target language code
    $shuwa->setTargetLang('it');
    // set the safe mode
    $shuwa->setSafeMode(true/false); 
    // set a proxy to the request
    $shuwa->setProxy("192.0.0.1:8080"); 
    // get the current proxy
    $shuwa->getProxy();
    // check if language code is valid
    $shuwa->checkLanguageCode('it'); 
    // detect the language code from a quote
    $shuwa->detectLangFromQuote("Lorem Ipsum");
    // translate a word or a quote
    $shuwa->translate('Hello world!');
    // translate a word or a quote using a proxy
    $shuwa->translate('Hello world!', true); 
    

use charlemagne\Shuwa\FShuwa; 

// will initialize ENGLISH => ITALIAN by default
$fileShuwa = new FShuwa(); 
// replace SOURCE & TARGET with your source language and target language code  
$fileShuwa = new FShuwa(SOURCE, TARGET);

    // returns true if quote is valid (See validation on Options)
    $fileShuwa->validate($quote);
    // replace ' to \' 
    $fileShuwa->bind($quote);
    // translate a laravel Language file
    $fileShuwa->laravelTranslation('INPUT_FILE_PATH', 'OUTPUT_FILE_PATH'); 
    // translate the whole $lang array from codeIgniter lang file
    $fileShuwa->codeIgniterTranslation($lang); 

$shuwa->setSafeMode(true);

use charlemagne\Shuwa\ProxySys; 

$system = new ProxySys(); 

// fill the list of proxyes 
$system->scrape(); 
// test proxyes and remove the slower ones. If list is empty, automatically call scrape()
$system->filter(); 
// optimize the list. If it isn't filtered, automatically call filter()
$system->optimize(); 
// fill the list in case the scrape() function doesn't works
$system->supportSource();
// same but fill the list with https proxyes
$system->supportSource(true);
// reload the list 
$system->reload(); 
// return a fresh new proxy and remove it from the list
$system->fire();