PHP code example of simp / translate

1. Go to this page and download the library: Download simp/translate 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/ */

    

simp / translate example snippets



    
    // Note: this will use the default translation languages, i.e., en to fr
    echo Translate::translate('Hello, How are you?');


   
    //Note: here we are manually setting the output language ie the original text is english which will be translated to Nyanja (Chichewa)
   echo Translate::translate('Hello, How are you?', to: 'ny');
   
   // This is also possible.
   echo Translate::translate('Moni', from: 'ny', to: 'en');
   
   // Sometimes you will need to just save the translation result some where to reuse it, in that way you dont have ask google to translate everytime.
   echo Translate::translate('Hello, How are you?', to: 'ny', cacheLocation: __DIR__.'/cache');