Js.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Translation\Block;
  7. use Magento\Framework\View\Element\Template;
  8. use Magento\Translation\Model\Js\Config;
  9. /**
  10. * JS translation block
  11. *
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class Js extends Template
  16. {
  17. /**
  18. * @var Config
  19. */
  20. protected $config;
  21. /**
  22. * @var \Magento\Translation\Model\FileManager
  23. */
  24. private $fileManager;
  25. /**
  26. * @param Template\Context $context
  27. * @param Config $config
  28. * @param \Magento\Translation\Model\FileManager $fileManager
  29. * @param array $data
  30. */
  31. public function __construct(
  32. Template\Context $context,
  33. Config $config,
  34. \Magento\Translation\Model\FileManager $fileManager,
  35. array $data = []
  36. ) {
  37. parent::__construct($context, $data);
  38. $this->config = $config;
  39. $this->fileManager = $fileManager;
  40. }
  41. /**
  42. * Is js translation set to dictionary mode
  43. *
  44. * @return bool
  45. */
  46. public function dictionaryEnabled()
  47. {
  48. return $this->config->dictionaryEnabled();
  49. }
  50. /**
  51. * Gets current js-translation.json timestamp
  52. *
  53. * @return string
  54. */
  55. public function getTranslationFileTimestamp()
  56. {
  57. return $this->fileManager->getTranslationFileTimestamp();
  58. }
  59. /**
  60. * Get translation file path
  61. *
  62. * @return string
  63. */
  64. public function getTranslationFilePath()
  65. {
  66. return $this->fileManager->getTranslationFilePath();
  67. }
  68. /**
  69. * Gets current version of the translation file.
  70. *
  71. * @return string
  72. * @since 100.3.0
  73. */
  74. public function getTranslationFileVersion()
  75. {
  76. return $this->fileManager->getTranslationFileVersion();
  77. }
  78. }