PHP code example of gtbabel / core
1. Go to this page and download the library: Download gtbabel/core 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/ */
gtbabel / core example snippets
use gtbabel\core\Gtbabel;
$gtbabel = new Gtbabel();
$gtbabel->start();
// any static or dynamic content
$gtbabel = new Gtbabel();
// set settings from php
$gtbabel->config(['languages' => [['code' => 'de', 'label' => 'Deutsch'], ['code' => 'en', 'label' => 'English']], ...]);
// set settings from json
$gtbabel->config('settings.json');
[
'languages' => [
[
'code' => 'de',
'label' => 'Deutsch',
'rtl' => false,
'hreflang_code' => 'de',
'google_translation_code' => 'de',
'microsoft_translation_code' => 'de',
'deepl_translation_code' => 'de',
'hidden' => false
],
[
'code' => 'en',
'label' => 'English',
'rtl' => false,
'hreflang_code' => 'en',
'google_translation_code' => 'en',
'microsoft_translation_code' => 'en',
'deepl_translation_code' => 'en',
'hidden' => false
],
[
'code' => 'fr',
'label' => 'Français',
'rtl' => false,
'hreflang_code' => 'fr',
'google_translation_code' => 'fr',
'microsoft_translation_code' => 'fr',
'deepl_translation_code' => 'fr',
'hidden' => false
],
[
'code' => 'af',
'label' => 'Afrikaans',
'rtl' => false,
'hreflang_code' => 'af',
'google_translation_code' => 'af',
'microsoft_translation_code' => 'af',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'am',
'label' => 'አማርኛ',
'rtl' => false,
'hreflang_code' => 'am',
'google_translation_code' => 'am',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ar',
'label' => 'العربية',
'rtl' => true,
'hreflang_code' => 'ar',
'google_translation_code' => 'ar',
'microsoft_translation_code' => 'ar',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'az',
'label' => 'Azərbaycan',
'rtl' => false,
'hreflang_code' => 'az',
'google_translation_code' => 'az',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'be',
'label' => 'беларускі',
'rtl' => false,
'hreflang_code' => 'be',
'google_translation_code' => 'be',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'bg',
'label' => 'български',
'rtl' => false,
'hreflang_code' => 'bg',
'google_translation_code' => 'bg',
'microsoft_translation_code' => 'bg',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'bn',
'label' => 'বাঙালির',
'rtl' => false,
'hreflang_code' => 'bn',
'google_translation_code' => 'bn',
'microsoft_translation_code' => 'bn',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'bs',
'label' => 'Bosanski',
'rtl' => false,
'hreflang_code' => 'bs',
'google_translation_code' => 'bs',
'microsoft_translation_code' => 'bs',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ca',
'label' => 'Català',
'rtl' => false,
'hreflang_code' => 'ca',
'google_translation_code' => 'ca',
'microsoft_translation_code' => 'ca',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ceb',
'label' => 'Cebuano',
'rtl' => false,
'hreflang_code' => null,
'google_translation_code' => 'ceb',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'co',
'label' => 'Corsican',
'rtl' => false,
'hreflang_code' => 'co',
'google_translation_code' => 'co',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'cs',
'label' => 'Český',
'rtl' => false,
'hreflang_code' => 'cs',
'google_translation_code' => 'cs',
'microsoft_translation_code' => 'cs',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'cy',
'label' => 'Cymraeg',
'rtl' => false,
'hreflang_code' => 'cy',
'google_translation_code' => 'cy',
'microsoft_translation_code' => 'cy',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'da',
'label' => 'Dansk',
'rtl' => false,
'hreflang_code' => 'da',
'google_translation_code' => 'da',
'microsoft_translation_code' => 'da',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'el',
'label' => 'ελληνικά',
'rtl' => false,
'hreflang_code' => 'el',
'google_translation_code' => 'el',
'microsoft_translation_code' => 'el',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'eo',
'label' => 'Esperanto',
'rtl' => false,
'hreflang_code' => 'eo',
'google_translation_code' => 'eo',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'es',
'label' => 'Español',
'rtl' => false,
'hreflang_code' => 'es',
'google_translation_code' => 'es',
'microsoft_translation_code' => 'es',
'deepl_translation_code' => 'es',
'hidden' => false
],
[
'code' => 'et',
'label' => 'Eesti',
'rtl' => false,
'hreflang_code' => 'et',
'google_translation_code' => 'et',
'microsoft_translation_code' => 'et',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'eu',
'label' => 'Euskal',
'rtl' => false,
'hreflang_code' => 'eu',
'google_translation_code' => 'eu',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'fa',
'label' => 'فارسی',
'rtl' => true,
'hreflang_code' => 'fa',
'google_translation_code' => 'fa',
'microsoft_translation_code' => 'fa',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'fi',
'label' => 'Suomalainen',
'rtl' => false,
'hreflang_code' => 'fi',
'google_translation_code' => 'fi',
'microsoft_translation_code' => 'fi',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ga',
'label' => 'Gaeilge',
'rtl' => false,
'hreflang_code' => 'ga',
'google_translation_code' => 'ga',
'microsoft_translation_code' => 'ga',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'gd',
'label' => 'Gàidhlig',
'rtl' => false,
'hreflang_code' => 'gd',
'google_translation_code' => 'gd',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'gl',
'label' => 'Galego',
'rtl' => false,
'hreflang_code' => 'gl',
'google_translation_code' => 'gl',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'gu',
'label' => 'ગુજરાતી',
'rtl' => false,
'hreflang_code' => 'gu',
'google_translation_code' => 'gu',
'microsoft_translation_code' => 'gu',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ha',
'label' => 'Hausa',
'rtl' => true,
'hreflang_code' => 'ha',
'google_translation_code' => 'ha',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'haw',
'label' => 'Hawaiian',
'rtl' => false,
'hreflang_code' => null,
'google_translation_code' => 'haw',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'he',
'label' => 'עברי',
'rtl' => true,
'hreflang_code' => 'he',
'google_translation_code' => 'he',
'microsoft_translation_code' => 'he',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'hi',
'label' => 'हिन्दी',
'rtl' => false,
'hreflang_code' => 'hi',
'google_translation_code' => 'hi',
'microsoft_translation_code' => 'hi',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'hmn',
'label' => 'Hmong',
'rtl' => false,
'hreflang_code' => null,
'google_translation_code' => 'hmn',
'microsoft_translation_code' => 'mww',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'hr',
'label' => 'Hrvatski',
'rtl' => false,
'hreflang_code' => 'hr',
'google_translation_code' => 'hr',
'microsoft_translation_code' => 'hr',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ht',
'label' => 'Kreyòl',
'rtl' => false,
'hreflang_code' => 'ht',
'google_translation_code' => 'ht',
'microsoft_translation_code' => 'ht',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'hu',
'label' => 'Magyar',
'rtl' => false,
'hreflang_code' => 'hu',
'google_translation_code' => 'hu',
'microsoft_translation_code' => 'hu',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'hy',
'label' => 'հայերեն',
'rtl' => false,
'hreflang_code' => 'hy',
'google_translation_code' => 'hy',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'id',
'label' => 'Indonesia',
'rtl' => false,
'hreflang_code' => 'id',
'google_translation_code' => 'id',
'microsoft_translation_code' => 'id',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ig',
'label' => 'Igbo',
'rtl' => false,
'hreflang_code' => 'ig',
'google_translation_code' => 'ig',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'is',
'label' => 'Icelandic',
'rtl' => false,
'hreflang_code' => 'is',
'google_translation_code' => 'is',
'microsoft_translation_code' => 'is',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'it',
'label' => 'Italiano',
'rtl' => false,
'hreflang_code' => 'it',
'google_translation_code' => 'it',
'microsoft_translation_code' => 'it',
'deepl_translation_code' => 'it',
'hidden' => false
],
[
'code' => 'ja',
'label' => '日本の',
'rtl' => false,
'hreflang_code' => 'ja',
'google_translation_code' => 'ja',
'microsoft_translation_code' => 'ja',
'deepl_translation_code' => 'ja',
'hidden' => false
],
[
'code' => 'jv',
'label' => 'Jawa',
'rtl' => false,
'hreflang_code' => 'jv',
'google_translation_code' => 'jv',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ka',
'label' => 'ქართული',
'rtl' => false,
'hreflang_code' => 'ka',
'google_translation_code' => 'ka',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'kk',
'label' => 'Қазақ',
'rtl' => false,
'hreflang_code' => 'kk',
'google_translation_code' => 'kk',
'microsoft_translation_code' => 'kk',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'km',
'label' => 'ខ្មែរ',
'rtl' => false,
'hreflang_code' => 'km',
'google_translation_code' => 'km',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'kn',
'label' => 'ಕನ್ನಡ',
'rtl' => false,
'hreflang_code' => 'kn',
'google_translation_code' => 'kn',
'microsoft_translation_code' => 'kn',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ko',
'label' => '한국의',
'rtl' => false,
'hreflang_code' => 'ko',
'google_translation_code' => 'ko',
'microsoft_translation_code' => 'ko',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ku',
'label' => 'Kurdî',
'rtl' => true,
'hreflang_code' => 'ku',
'google_translation_code' => 'ku',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ky',
'label' => 'Кыргыз',
'rtl' => false,
'hreflang_code' => 'ky',
'google_translation_code' => 'ky',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'la',
'label' => 'Latine',
'rtl' => false,
'hreflang_code' => 'la',
'google_translation_code' => 'la',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'lb',
'label' => 'Lëtzebuergesch',
'rtl' => false,
'hreflang_code' => 'lb',
'google_translation_code' => 'lb',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'lo',
'label' => 'ລາວ',
'rtl' => false,
'hreflang_code' => 'lo',
'google_translation_code' => 'lo',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'lt',
'label' => 'Lietuvos',
'rtl' => false,
'hreflang_code' => 'lt',
'google_translation_code' => 'lt',
'microsoft_translation_code' => 'lt',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'lv',
'label' => 'Latvijas',
'rtl' => false,
'hreflang_code' => 'lv',
'google_translation_code' => 'lv',
'microsoft_translation_code' => 'lv',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mg',
'label' => 'Malagasy',
'rtl' => false,
'hreflang_code' => 'mg',
'google_translation_code' => 'mg',
'microsoft_translation_code' => 'mg',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mi',
'label' => 'Maori',
'rtl' => false,
'hreflang_code' => 'mi',
'google_translation_code' => 'mi',
'microsoft_translation_code' => 'mi',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mk',
'label' => 'македонски',
'rtl' => false,
'hreflang_code' => 'mk',
'google_translation_code' => 'mk',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ml',
'label' => 'മലയാളം',
'rtl' => false,
'hreflang_code' => 'ml',
'google_translation_code' => 'ml',
'microsoft_translation_code' => 'ml',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mn',
'label' => 'Монгол',
'rtl' => false,
'hreflang_code' => 'mn',
'google_translation_code' => 'mn',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mr',
'label' => 'मराठी',
'rtl' => false,
'hreflang_code' => 'mr',
'google_translation_code' => 'mr',
'microsoft_translation_code' => 'mr',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ms',
'label' => 'Malay',
'rtl' => false,
'hreflang_code' => 'ms',
'google_translation_code' => 'ms',
'microsoft_translation_code' => 'ms',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'mt',
'label' => 'Malti',
'rtl' => false,
'hreflang_code' => 'mt',
'google_translation_code' => 'mt',
'microsoft_translation_code' => 'mt',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'my',
'label' => 'မြန်မာ',
'rtl' => false,
'hreflang_code' => 'my',
'google_translation_code' => 'my',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ne',
'label' => 'नेपाली',
'rtl' => false,
'hreflang_code' => 'ne',
'google_translation_code' => 'ne',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'nl',
'label' => 'Nederlands',
'rtl' => false,
'hreflang_code' => 'nl',
'google_translation_code' => 'nl',
'microsoft_translation_code' => 'nl',
'deepl_translation_code' => 'nl',
'hidden' => false
],
[
'code' => 'no',
'label' => 'Norsk',
'rtl' => false,
'hreflang_code' => 'no',
'google_translation_code' => 'no',
'microsoft_translation_code' => 'nb',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ny',
'label' => 'Nyanja',
'rtl' => false,
'hreflang_code' => 'ny',
'google_translation_code' => 'ny',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'pa',
'label' => 'ਪੰਜਾਬੀ',
'rtl' => false,
'hreflang_code' => 'pa',
'google_translation_code' => 'pa',
'microsoft_translation_code' => 'pa',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'pl',
'label' => 'Polski',
'rtl' => false,
'hreflang_code' => 'pl',
'google_translation_code' => 'pl',
'microsoft_translation_code' => 'pl',
'deepl_translation_code' => 'pl',
'hidden' => false
],
[
'code' => 'ps',
'label' => 'پښتو',
'rtl' => true,
'hreflang_code' => 'ps',
'google_translation_code' => 'ps',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'pt-br',
'label' => 'Português (Brasil)',
'rtl' => false,
'hreflang_code' => 'pt',
'google_translation_code' => 'pt',
'microsoft_translation_code' => 'pt-br',
'deepl_translation_code' => 'pt',
'hidden' => false
],
[
'code' => 'pt-pt',
'label' => 'Português (Portugal)',
'rtl' => false,
'hreflang_code' => 'pt',
'google_translation_code' => 'pt',
'microsoft_translation_code' => 'pt-pt',
'deepl_translation_code' => 'pt',
'hidden' => false
],
[
'code' => 'ro',
'label' => 'Românesc',
'rtl' => false,
'hreflang_code' => 'ro',
'google_translation_code' => 'ro',
'microsoft_translation_code' => 'ro',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ru',
'label' => 'Русский',
'rtl' => false,
'hreflang_code' => 'ru',
'google_translation_code' => 'ru',
'microsoft_translation_code' => 'ru',
'deepl_translation_code' => 'ru',
'hidden' => false
],
[
'code' => 'sd',
'label' => 'سنڌي',
'rtl' => false,
'hreflang_code' => 'sd',
'google_translation_code' => 'sd',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'si',
'label' => 'සිංහලයන්',
'rtl' => false,
'hreflang_code' => 'si',
'google_translation_code' => 'si',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sk',
'label' => 'Slovenský',
'rtl' => false,
'hreflang_code' => 'sk',
'google_translation_code' => 'sk',
'microsoft_translation_code' => 'sk',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sl',
'label' => 'Slovenski',
'rtl' => false,
'hreflang_code' => 'sl',
'google_translation_code' => 'sl',
'microsoft_translation_code' => 'sl',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sm',
'label' => 'Samoa',
'rtl' => false,
'hreflang_code' => 'sm',
'google_translation_code' => 'sm',
'microsoft_translation_code' => 'sm',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sn',
'label' => 'Shona',
'rtl' => false,
'hreflang_code' => 'sn',
'google_translation_code' => 'sn',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'so',
'label' => 'Soomaali',
'rtl' => false,
'hreflang_code' => 'so',
'google_translation_code' => 'so',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sq',
'label' => 'Shqiptar',
'rtl' => false,
'hreflang_code' => 'sq',
'google_translation_code' => 'sq',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sr-cy',
'label' => 'Српски (ћирилица)',
'rtl' => false,
'hreflang_code' => 'sr',
'google_translation_code' => 'sr',
'microsoft_translation_code' => 'sr-Cyrl',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sr-la',
'label' => 'Српски (латински)',
'rtl' => false,
'hreflang_code' => 'sr',
'google_translation_code' => 'sr',
'microsoft_translation_code' => 'sr-Latn',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'su',
'label' => 'Sunda',
'rtl' => false,
'hreflang_code' => 'su',
'google_translation_code' => 'su',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'sv',
'label' => 'Svenska',
'rtl' => false,
'hreflang_code' => 'sv',
'google_translation_code' => 'sv',
'microsoft_translation_code' => 'sv',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ta',
'label' => 'தமிழ்',
'rtl' => false,
'hreflang_code' => 'ta',
'google_translation_code' => 'ta',
'microsoft_translation_code' => 'ta',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'te',
'label' => 'Telugu',
'rtl' => false,
'hreflang_code' => 'te',
'google_translation_code' => 'te',
'microsoft_translation_code' => 'te',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'tg',
'label' => 'Тоҷикистон',
'rtl' => false,
'hreflang_code' => 'tg',
'google_translation_code' => 'tg',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'th',
'label' => 'ไทย',
'rtl' => false,
'hreflang_code' => 'th',
'google_translation_code' => 'th',
'microsoft_translation_code' => 'th',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'tr',
'label' => 'Türk',
'rtl' => false,
'hreflang_code' => 'tr',
'google_translation_code' => 'tr',
'microsoft_translation_code' => 'tr',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'uk',
'label' => 'Український',
'rtl' => false,
'hreflang_code' => 'uk',
'google_translation_code' => 'uk',
'microsoft_translation_code' => 'uk',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'ur',
'label' => 'اردو',
'rtl' => true,
'hreflang_code' => 'ur',
'google_translation_code' => 'ur',
'microsoft_translation_code' => 'ur',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'uz',
'label' => 'O\'zbekiston',
'rtl' => false,
'hreflang_code' => 'uz',
'google_translation_code' => 'uz',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'vi',
'label' => 'Tiếng việt',
'rtl' => false,
'hreflang_code' => 'vi',
'google_translation_code' => 'vi',
'microsoft_translation_code' => 'vi',
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'xh',
'label' => 'IsiXhosa',
'rtl' => false,
'hreflang_code' => 'xh',
'google_translation_code' => 'xh',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'yi',
'label' => 'ייִדיש',
'rtl' => true,
'hreflang_code' => 'yi',
'google_translation_code' => 'yi',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'yo',
'label' => 'Yoruba',
'rtl' => false,
'hreflang_code' => 'yo',
'google_translation_code' => 'yo',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
],
[
'code' => 'zh-cn',
'label' => '中文(简体)',
'rtl' => false,
'hreflang_code' => 'zh-cn',
'google_translation_code' => 'zh-cn',
'microsoft_translation_code' => 'zh-Hans',
'deepl_translation_code' => 'zh',
'hidden' => false
],
[
'code' => 'zh-tw',
'label' => '中文(繁體)',
'rtl' => false,
'hreflang_code' => 'zh-tw',
'google_translation_code' => 'zh-tw',
'microsoft_translation_code' => 'zh-Hant',
'deepl_translation_code' => 'zh',
'hidden' => false
],
[
'code' => 'zu',
'label' => 'Zulu',
'rtl' => false,
'hreflang_code' => 'zu',
'google_translation_code' => 'zu',
'microsoft_translation_code' => null,
'deepl_translation_code' => null,
'hidden' => false
]
],
'lng_source' => 'de',
'lng_target' => null, // this gets automatically determined by the current url; you can set this manually (e.g. in a non-host based environment)
'database' => [
'type' => 'sqlite',
'filename' => 'data.db',
'table' => 'translations'
// mysql/pgsql is also supported
/*
'type' => 'mysql',
'host' => '127.0.0.1',
'username' => 'xxxxxx',
'password' => 'xxxxxx',
'database' => 'xxxxxx',
'port' => 3306,
'table' => 'translations'
*/
],
'log_folder' => '/logs',
'redirect_root_domain' => 'browser', // browser|source|ip
'basic_auth' => null, // provide basic auth (in the format "username:password") if you use Gtbabel in a password protected environment
'translate_html' => true,
'translate_html_
$gtbabel = new Gtbabel();
$gtbabel->config([...]);
$gtbabel->translate('<p>Dies ist ein Test!</p>'); // <p>This is a test!</p>
$gtbabel->translate('datenschutz', 'en', 'de', 'slug'); // data-protection
$gtbabel->tokenize('<p>Dies ist ein Test!</p>'); // [['string' => 'This is a test!', 'context' => null]]
// only run this once
add_action('admin_init', function () {
get_role('editor')->add_cap('gtbabel__translation_assistant');
get_role('editor')->add_cap('gtbabel__translate_en');
get_role('editor')->add_cap('gtbabel__translate_fr');
});
if (function_exists('gtbabel__')) {
wp_localize_script('script', 'strings', [
'baseurl' => gtbabel__(get_bloginfo('url')),
'lng' => gtbabel_current_lng(),
'example' => gtbabel__('Dies ist ein Test')
]);
}
[
'selector' => '/html/body//@*[starts-with(name(), \'data-\')]/parent::*',
'attribute' => 'data-*',
'context' => null
];
[
'selector' => '.foo[data-bar]',
'attribute' => 'data-bar',
'context' => null
];
'languages' => [
[
'code' => 'de',
/* ... */
'url_base' => 'https://www.tld.com'
'url_prefix' => 'de'
],
[
'code' => 'en',
/* ... */
'url_base' => 'https://www.tld.com'
'url_prefix' => 'en'
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_prefix' => ''
],
[
'code' => 'en',
/* ... */
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_prefix' => 'deutsch'
],
[
'code' => 'en',
/* ... */
'url_prefix' => 'english'
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_base' => 'https://de.tld.com'
'url_prefix' => ''
],
[
'code' => 'en',
/* ... */
'url_base' => 'https://en.tld.com'
'url_prefix' => ''
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_base' => 'https://www.tld.de'
'url_prefix' => ''
],
[
'code' => 'en',
/* ... */
'url_base' => 'https://www.tld.com'
'url_prefix' => ''
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_base' => 'https://www.tld.com/some/sub/path'
'url_prefix' => 'de'
],
[
'code' => 'en',
/* ... */
'url_base' => 'https://www.tld.com/some/sub/path'
'url_prefix' => 'en'
]
/* ... */
]
'languages' => [
[
'code' => 'de',
/* ... */
'url_prefix' => ''
],
[
'code' => 'en',
/* ... */
'url_prefix' => ''
]
/* ... */,
]
/* ... */
'unchecked_strings' => is_user_logged_in() ? 'trans' : 'hide'
/* ... */
if (function_exists('gtbabel_languagepicker')) {
echo '<ul class="lngpicker">';
foreach (gtbabel_languagepicker() as $val) {
echo '<li>';
echo '<a href="' . $val['url'] . '"' . ($val['active'] ? ' class="active"' : '') . '>';
echo $val['label'];
echo '</a>';
echo '</li>';
}
echo '</ul>';
}
gtbabel_current_lng() // 'en'
gtbabel_source_lng() // 'de'
gtbabel_languages() // ['de','en']
gtbabel_default_language_codes() // ['de','en','fr','af','am','ar','az','be','bg','bn','bs','ca','ceb','co','cs','cy','da','el','eo','es','et','eu','fa','fi','ga','gd','gl','gu','ha','haw','he','hi','hmn','hr','ht','hu','hy','id','ig','is','it','ja','jv','ka','kk','km','kn','ko','ku','ky','la','lb','lo','lt','lv','mg','mi','mk','ml','mn','mr','ms','mt','my','ne','nl','no','ny','pa','pl','ps','pt','ro','ru','sd','si','sk','sl','sm','sn','so','sq','sr','su','sv','ta','te','tg','th','tr','uk','ur','uz','vi','xh','yi','yo','zh-cn','zh-tw','zu']
gtbabel_default_languages() // [['code' => 'de', 'label' => 'Deutsch'], ['code' => 'en', 'label' => 'English'], ...]
gtbabel_language_label('en') // 'English'
gtbabel_default_settings() // ['languages' => [['code' => 'de', 'label' => 'Deutsch'], ['code' => 'en', 'label' => 'English'], ...], 'log_folder' => '/logs', ...]
gtbabel_default_settings(['log_folder' => '/foo']) // ['languages' => [['code' => 'de', 'label' => 'Deutsch'], ['code' => 'en', 'label' => 'English'], ...], 'log_folder' => '/foo', ...]
gtbabel_referer_lng() // 'de'
gtbabel_languagepicker() // [['code' => 'de', 'label' => 'Deutsch', 'url' => 'https://tld.com/de/nudel', 'active' => true], ['code' => 'en', 'label' => 'English', 'url' => 'https://tld.com/en/noodle', 'active' => false], ...]
gtbabel__('Hallo') // 'Hi there'
global $gtbabel;
$gtbabel = new Gtbabel();
$gtbabel->config(['lng_source' => 'de', 'lng_target' => 'ar');
gtbabel__('Hallo'); // مرحبا
$url = gtbabel__('https://gtbabel.com');
echo '<a href="https://www.facebook.com/sharer/sharer.php?u=' . urlencode($url) . '">Facebook</a>';
gtbabel__('Hallo', 'en', 'de') // 'Hi there'
gtbabel__('Hi there', 'de', 'en') // 'Hallo'
gtbabel__('<p>Hallo <a href="/datenschutz">Datenschutz</a>!</p>'); // '<p>Hello <a href="/en/data-protection">data protection</a>!</p>'
gtbabel__('/datenschutz'); // '/en/data-protection'
gtbabel__('datenschutz', null, null, 'slug'); // 'data-protection'
$s = gtbabel__($s, gtbabel_source_lng(), gtbabel_current_lng(), 'search_term');
$body = gtbabel__($body);
$message = gtbabel__($message);
// before
$message = 'Hello John Doe,';
// after
$message = 'Hello <span class="notranslate force-tokenize">John Doe</span>,';
[
'provider' => 'custom_provider',
'api_keys' => ['1337'],
'throttle_chars_per_month' => 1000000,
'lng' => null,
'label' => 'My custom provider',
'api_url' => 'https://tld.com/api/?str=%str%&from=%lng_source%&to=%lng_target%&api_key=%api_key%'
'disabled' => false
]
js
if (typeof gtbabel__ === 'function') {
gtbabel__('Registered string');
}