PHP code example of michalskoula / codeigniter-ai-translation

1. Go to this page and download the library: Download michalskoula/codeigniter-ai-translation 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/ */

    

michalskoula / codeigniter-ai-translation example snippets



nslator = new MichalSkoula\CodeIgniterAITranslation\Translator(
    'your-api-key',           // Anthropic Claude API key
    'cs',                     // source language (need to match you directory name)
    'en',                     // target language (need to match you directory name; will be created automatically)
    'application/language',   // path to your language files
    3                         // CodeIgniter version (3 - default, 4)
);

// if $file is null, if will translate all files in the directory
$result = $translator->translate($file);

echo "Translation process completed." . PHP_EOL;
echo "Total files processed: " . $result->getProcessed() . PHP_EOL;
echo "Total items translated: " . $result->getTranslated() . PHP_EOL;
echo "Total items failed: " . $result->getFailed() . PHP_EOL;
if ($result->isError()) {
    echo 'Error: ' . $result->getErrorMessage() . PHP_EOL;
}