setLanguage
setLanguage(string $languageName)
All the lang strings in Grocery CRUD Enterprise are editable so we can have a multilingual functionality. The syntax is simple:
$crud->setLanguage('Spanish')
The functionality also known as Locale or i18n (shortcut of Internationalization) is available in 34 languages so far including:
- Arabic
- Bengali
- Bulgarian
- Catalan
- Chinese
- Croatian
- Czech
- Danish
- Dutch
- English
- French
- German
- Greek
- Hindi
- Hungarian
- Indonesian
- Italian
- Japanese
- Korean
- Lithuanian
- Mongolian
- Norwegian
- Persian
- Polish
- Romanian
- Russian
- Slovak
- Spanish
- Thai
- Turkish
- Ukrainian
- Vietnamese
- pt-BR.Portuguese
- pt-PT.Portuguese
Example
A more specific example can be found below:
$crud->setTable('customers');
$crud->setSubject('Cliente', 'Clientes');
$crud->fields(['customerName','phone','addressLine1','creditLimit']);
$crud->columns(['customerName','phone','addressLine1','creditLimit']);
$crud->setLanguage('Spanish');
$crud->displayAs('customerName', 'Nombre')
->displayAs('phone', 'Teléfono')
->displayAs('addressLine1', 'Dirección')
->displayAs('creditLimit', 'Límite de crédito');
$output = $crud->render();
As you can also see all the dynamic strings (expect of the database field names) are translated in Spanish: