/** * 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; }
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()); }
public function testLoadDataNoTheme() { $forceReload = true; $this->expectsSetConfig(null, null); $this->moduleList->expects($this->once())->method('getNames')->will($this->returnValue([])); $this->appState->expects($this->once())->method('getAreaCode')->will($this->returnValue('frontend')); $this->packDictionary->expects($this->once())->method('getDictionary')->will($this->returnValue([])); $this->resource->expects($this->any())->method('getTranslationArray')->will($this->returnValue([])); $this->assertEquals($this->translate, $this->translate->loadData(null, $forceReload)); }
/** * Loading current translation from DB * * @return $this */ protected function _loadDbTranslation() { $data = $this->_translateResource->getTranslationArray(null, $this->getLocale()); $this->_addData($data); return $this; }
/** * Loading current translation from DB * * @return $this */ protected function _loadDbTranslation() { $data = $this->_translateResource->getTranslationArray(null, $this->getLocale()); $this->_addData(array_map("htmlspecialchars_decode", $data)); return $this; }
/** * Loading current translation from DB * * @param bool $forceReload * @return $this */ protected function _loadDbTranslation($forceReload = false) { $arr = $this->_translateResource->getTranslationArray(null, $this->getLocale()); $this->_addData($arr, $this->getConfig('scope'), $forceReload); return $this; }