HtmlLang.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ b/Jatgque0co1xELSH6ftoi3QM2YYnRgYQR6FsB7GkU=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.2
  11. */
  12. /**
  13. * add language to html lang tag
  14. * active locale is retrieved from translate adapter
  15. */
  16. namespace Cube\View\Helper;
  17. class HtmlLang extends AbstractHelper
  18. {
  19. /**
  20. * default language
  21. */
  22. const DEFAULT_LANGUAGE = 'en';
  23. /**
  24. *
  25. * language string
  26. *
  27. * @var string
  28. */
  29. protected $_htmlLang = self::DEFAULT_LANGUAGE;
  30. /**
  31. *
  32. * head title method
  33. * will output the currently set locale after it has been properly formatted
  34. *
  35. * @return string
  36. */
  37. public function htmlLang()
  38. {
  39. $locale = $this->getTranslate()->getLocale();
  40. if (empty($locale)) {
  41. $locale = self::DEFAULT_LANGUAGE;
  42. }
  43. else {
  44. $locale = strtok($locale, '_');
  45. }
  46. return $locale;
  47. }
  48. }