PHP code example of nativemind / module-translation

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

    

nativemind / module-translation example snippets


use NativeMind\Translation\Helper\Data as TranslationHelper;

// Initialize
$translationHelper = $this->translationHelper;

// Simple translation
$translated = $translationHelper->translateText(
    'Hello World', 
    'ru_RU', 
    $storeId
);

// Translate array
$data = ['title' => 'Product Title', 'description' => 'Product Description'];
$translated = $translationHelper->translateArray($data, 'ru_RU');
bash
composer nto module:enable NativeMind_Translation
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush
bash
# Translate all products
php bin/magento nativemind:translate:products

# Translate specific products
php bin/magento nativemind:translate:products --product-ids="1,2,3"

# Translate for specific stores
php bin/magento nativemind:translate:products --store-ids="2,3,4"

# Force translation (overwrite existing)
php bin/magento nativemind:translate:products --force

# Translate categories
php bin/magento nativemind:translate:categories