Skip to content

Commit b3a1c7e

Browse files
committed
Refactored getting translation file version into a more desirable state, still using the modified timestamp for now.
1 parent a1dab12 commit b3a1c7e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

app/code/Magento/Translation/Block/Js.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function getTranslationFilePath()
7272
/**
7373
* @return string
7474
*/
75-
public function getTranslationFileFullPath()
75+
public function getTranslationFileVersion()
7676
{
77-
return $this->fileManager->getTranslationFileFullPath();
77+
return $this->fileManager->getTranslationFileVersion();
7878
}
7979
}

app/code/Magento/Translation/Model/FileManager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getTranslationFileTimestamp()
7373
/**
7474
* @return string
7575
*/
76-
public function getTranslationFileFullPath()
76+
protected function getTranslationFileFullPath()
7777
{
7878
return $this->directoryList->getPath(DirectoryList::STATIC_VIEW) .
7979
\DIRECTORY_SEPARATOR .
@@ -104,4 +104,12 @@ public function updateTranslationFileContent($content)
104104
}
105105
$this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
106106
}
107+
108+
/**
109+
* @return string
110+
*/
111+
public function getTranslationFileVersion()
112+
{
113+
return sha1($this->getTranslationFileTimestamp() . $this->getTranslationFilePath());
114+
}
107115
}

app/code/Magento/Translation/view/base/templates/translate.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
$.initNamespaceStorage('mage-translation-file-version');
2727
versionObj = $.localStorage.get('mage-translation-file-version');
2828

29-
<?php $version = sha1(sha1_file($block->getTranslationFileFullPath()) . $block->getTranslationFilePath()); ?>
29+
<?php $version = $block->getTranslationFileVersion(); ?>
3030

3131
if (versionObj.version !== '<?= /* @noEscape */ $version ?>') {
3232
dependencies.push(

0 commit comments

Comments
 (0)