PHP code example of dialect / transedit

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

    

dialect / transedit example snippets


   transEdit()->setKey('greeting', 'Hello');
   

   $value = transEdit()->getKey('greeting'); // returns "Hello"
   

   // Set a key
   transEdit('example.key', 'Some value', 'locale'); // 'locale' is optional

   // Get a key
   transEdit('example.key'); // returns "Some value"
   

   // Positional variables
   transEdit('You have $1 months left on your subscription of $2.', ['12', 'Netflix']);

   // Named variables
   transEdit('You have $MONTHS months left on your subscription of $SERVICE.', [
       'MONTHS' => '12',
       'SERVICE' => 'Netflix'
   ]);
   

   transEdit()->enableEditMode();  // Double-click on highlighted text to edit
   transEdit()->disableEditMode(); // Turn off in-browser editing
   

   // If the phrase does not exist in the database, TransEdit will create it
   transEdit('Welcome to our website!');

   // Optionally, you can 

   echo transEdit('Welcome to our website!');
   

   transEdit('Hello, $NAME! Thank you for joining us.', ['NAME' => 'Alice']);
   

   transEdit()->enableEditMode();
   



return [
  "recipe" => "Recept",
];

transEdit('article.recipe');

// Create or update a language name
transEdit()->setLocaleLanguageName('en', 'English');

// ----- Using Keys ----- //
// Set a key for the default or current locale
transEdit()->setKey('header.welcome', 'Welcome to our website');
transEdit('header.welcome', 'Welcome to our website'); // short syntax

// Retrieve a key
echo transEdit('header.welcome'); // "Welcome to our website"

// ----- Using Phrases ----- //
// Directly create or retrieve a phrase
echo transEdit('This is a phrase-based translation.');

// With variables
echo transEdit('Thank you, $NAME, for signing up!', ['NAME' => 'Alice']);

// Enable edit-mode (for the current user/session)
transEdit()->enableEditMode();
bash
   php artisan vendor:publish --provider="Dialect\TransEdit\TransEditServiceProvider"
   
bash
   php artisan migrate
   
bash
php artisan transedit:add-missing-phrases
bash
  php artisan transedit:add-missing-phrases --direct=1
  
bash
php artisan vendor:publish --provider="Dialect\TransEdit\TransEditServiceProvider"