1. Go to this page and download the library: Download alnaggar/turjuman 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/ */
use Alnaggar\Turjuman\Turjuman;
Turjuman::group(function () {
// Define your localized routes here
}, [
'route_aliases' => [
'fr' => [
'/products' => '/produits'
]
]
]);
use Alnaggar\Turjuman\Turjuman;
$url = Turjuman::getLocalizedUrl('/products', 'fr');
// Returns the URL for the 'fr' locale: '/fr/produits'
use Alnaggar\Turjuman\Turjuman;
Turjuman::group(function () {
// Define your localized routes here
}, [
'supported_locales' => [...], // Specify supported locales
'default_locale' => 'en', // Set the default locale
// Add more group attributes as needed
]);
use Alnaggar\Turjuman\Turjuman;
// Adding Macros
Turjuman::macro('customMethod', function () {
// Your custom logic here
});
/// Adding Mixins
Turjuman::mixin(new MyCustomMixin());
// routes/web.php
use Alnaggar\Turjuman\Turjuman;
Turjuman::group(function () {
// Define your localized routes here
}, [
'continent' => 'Africa',
'common_language' => 'Arabic'
]);
// YourClass.php
use Alnaggar\Turjuman\Turjuman;
public function getDetails()
{
$currency = Turjuman::getCurrentLocale()['currency'];
$continent = Turjuman::getCurrentAttributes()->continent;
$commonLanguage = Turjuman::getCurrentAttributes()->getCommonLanguage();
// ...
}
use Alnaggar\Turjuman\Facades\Turjuman;
Turjuman::group(function () {
// Define your localized routes here
}, [
'default_locale' => 'en',
'display_location' => 'lang',
// More custom attributes...
]);
use Alnaggar\Turjuman\Turjuman;
Turjuman::group(function () {
// Define your localized routes here
Turjuman::ignore(function() {
// Define your non-localized routes here
});
});
// App/Providers/AppServiceProvider.php
use \Alnaggar\Turjuman\Locale;
use \Alnaggar\Turjuman\Turjuman;
$locales = [
new Locale(['code' => 'fr', 'name' => 'French', 'native' => 'français', 'script' => 'Latn']),
new Locale(['code' => 'es', 'name' => 'Spanish', 'native' => 'español', 'script' => 'Latn']),
];
Turjuman::addConfigLocales($locales);
// App/Providers/AppServiceProvider.php
use \Alnaggar\Turjuman\Locale;
use \Alnaggar\Turjuman\Turjuman;
$locales = [
// Define your locales.
];
Turjuman::setConfigLocales($locales);
// App/Providers/AppServiceProvider.php
use \Alnaggar\Turjuman\Turjuman;
Turjuman::setConfigDefaultLocale('fr');
use \Alnaggar\Turjuman\Turjuman;
$configAttributes = Turjuman::getConfigAttributes();
use \Alnaggar\Turjuman\Turjuman;
$currentGroup = Turjuman::getCurrentGroup();
use \Alnaggar\Turjuman\Turjuman;
$currentAttributes = Turjuman::getCurrentAttributes();
use \Alnaggar\Turjuman\Turjuman;
Turjuman::setCurrentLocale('es');
use \Alnaggar\Turjuman\Turjuman;
$arabicLocale = Turjuman::getLocale('ar');
use \Alnaggar\Turjuman\Turjuman;
$supportedLocales = Turjuman::getSupportedLocales();
use \Alnaggar\Turjuman\Turjuman;
$defaultLocale = Turjuman::getDefaultLocale();
use \Alnaggar\Turjuman\Turjuman;
$currentLocale = Turjuman::getCurrentLocale();
use \Alnaggar\Turjuman\Turjuman;
$spanishUrl = Turjuman::getLocalizedUrl('/about', 'es');
use \Alnaggar\Turjuman\Turjuman;
$originalUrl = Turjuman::getNonLocalizedUrl('/acerca-de');
use \Alnaggar\Turjuman\Turjuman;
$isLocalizedUrl = Turjuman::isLocalizedUrl('/contact');
use \Alnaggar\Turjuman\Turjuman;
$isLocalizedUrl = Turjuman::isLocalizedRoute('main.contact');
use \Alnaggar\Turjuman\Turjuman;
$isSupported = Turjuman::isSupportedLocale('es');
use \Alnaggar\Turjuman\Turjuman;
$isCurrent = Turjuman::isCurrentLocale('fr');
use \Alnaggar\Turjuman\Turjuman;
$isDefault = Turjuman::isDefaultLocale('en');
use \Alnaggar\Turjuman\Turjuman;
$localesCurrencies = Turjuman::getLocalesByProperty('currency', 'USD');
use \Alnaggar\Turjuman\Turjuman;
$localizedPath = Turjuman::getLocalizedPagePath('contact', 'fr');
// Get the localized URL for a given path and locale
$url = turjuman('/about', 'ar');