コード例 #1
0
 /**
  * Clears cache and updates translations file
  *
  * @return array
  */
 public function updateAndGetTranslations()
 {
     $this->eventManager->dispatch('adminhtml_cache_flush_system');
     $translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale());
     $this->fileManager->updateTranslationFileContent(json_encode($translations));
     return $translations;
 }
コード例 #2
0
ファイル: FileManagerTest.php プロジェクト: tingyeeh/magento2
 public function testGetTranslationFilePath()
 {
     $path = 'path';
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
     $this->assertEquals($path, $this->model->getTranslationFilePath());
 }
コード例 #3
0
 /**
  * Include RequireJs inline translation configuration as an asset on the page
  * @return void
  */
 private function addInlineTranslationConfig()
 {
     if ($this->inline->isAllowed()) {
         $after = RequireJsConfig::REQUIRE_JS_FILE_NAME;
         $tConfig = $this->fileManager->createTranslateConfigAsset();
         $assetCollection = $this->pageConfig->getAssetCollection();
         $assetCollection->insert($tConfig->getFilePath(), $tConfig, $after);
     }
 }
コード例 #4
0
 public function testUpdateAndGetTranslations()
 {
     $translations = ['phrase1' => 'translated1', 'phrase2' => 'translated2'];
     $this->eventManagerMock->expects($this->once())->method('dispatch');
     $this->translateResourceMock->expects($this->once())->method('getTranslationArray')->willReturn($translations);
     $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn('en_US');
     $this->fileManagerMock->expects($this->once())->method('updateTranslationFileContent');
     $this->assertEquals($translations, $this->model->updateAndGetTranslations());
 }
コード例 #5
0
 public function testCreateTranslateConfigAsset()
 {
     $path = 'relative path';
     $expectedPath = $path . '/' . FileManager::TRANSLATION_CONFIG_FILE_NAME;
     $fileMock = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->once())->method('getPath')->willReturn($path);
     $this->assetRepoMock->expects($this->once())->method('createArbitrary')->with($expectedPath, '')->willReturn($fileMock);
     $this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
 }
コード例 #6
0
ファイル: Js.php プロジェクト: pradeep-wagento/magento2
 /**
  * @return string
  */
 public function getTranslationFilePath()
 {
     return $this->fileManager->getTranslationFilePath();
 }