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:

  1. Arabic
  2. Bengali
  3. Bulgarian
  4. Catalan
  5. Chinese
  6. Croatian
  7. Czech
  8. Danish
  9. Dutch
  10. English
  11. French
  12. German
  13. Greek
  14. Hindi
  15. Hungarian
  16. Indonesian
  17. Italian
  18. Japanese
  19. Korean
  20. Lithuanian
  21. Mongolian
  22. Norwegian
  23. Persian
  24. Polish
  25. Romanian
  26. Russian
  27. Slovak
  28. Spanish
  29. Thai
  30. Turkish
  31. Ukrainian
  32. Vietnamese
  33. pt-BR.Portuguese
  34. 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: