PHP code example of basteyy / php-i18n

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

    

basteyy / php-i18n example snippets


// Content of /var/www/index.php

use basteyy\I18n\I18n;

I18n::addTranslationFolder(__DIR__ . '/lang/');
I18n::addTranslationFolder(__DIR__ . '/another_folder/');
I18n::setTranslationLanguage('de_DE');

echo __('Add');
// Result: Hinzufügen

echo __("Remove");
// Result: Entfernen

echo __('Remove %s Item\'s ', 3212);
// Result: 3212 Dinge entfernen

echo __('A new string');
// Result: A new string

echo __('A new string with placeholder %s', 'inside');
// Result: A new string with placeholder inside
bash
composer 
bash
php vendor/basteyy/php-i18n/src/bin/I18nBaker source_folder target_file options --no-comments
bash
php vendor/basteyy/php-i18n/src/bin/I18nBaker /var/www/src/templates/ /var/www/src/translations/dk_DK.ini
bash
php vendor/basteyy/php-i18n/src/bin/I18nBaker /var/www/src/templates/ /var/www/src/translations/dk_DK.ini --no-comments