public function revisions(Request $request) { $translation = $this->translation->findTranslationByKey($request->get('key')); $translation = $translation->translate($request->get('locale')); if (null === $translation) { return response()->json(['<tr><td>' . trans('translation::translations.No Revisions yet') . '</td></tr>']); } return response()->json($this->formatRevisionHistory($translation->revisionHistory)); }
/** * Get the file translations & the database translations, overwrite the file translations by db translations * @return TranslationGroup */ public function getFileAndDatabaseMergedTranslations() { $allFileTranslations = $this->fileTranslations->all(); $allDatabaseTranslations = $this->databaseTranslations->allFormatted(); foreach ($allFileTranslations as $locale => $fileTranslation) { foreach ($fileTranslation as $key => $translation) { if (isset($allDatabaseTranslations[$locale][$key])) { $allFileTranslations[$locale][$key] = $allDatabaseTranslations[$locale][$key]; unset($allDatabaseTranslations[$locale][$key]); } } } $this->addDatabaseOnlyTranslations($allFileTranslations, $allDatabaseTranslations); $this->filterOnlyActiveLocales($allFileTranslations); return new TranslationGroup($allFileTranslations); }
public function import(UploadedFile $file) { $csv = Reader::createFromPath($file->getRealPath()); $csv->detectDelimiterList(5, [',', ';']); $headers = $csv->fetchOne(); $csv->setOffset(1); $csv->each(function ($row) use($headers) { try { $row = array_combine($headers, $row); } catch (\Exception $e) { return true; } $key = array_get($row, 'key'); array_shift($row); $data = []; foreach ($row as $locale => $value) { $data[$locale] = ['value' => $value]; } $this->translation->updateFromImport($key, $data); return true; }); }
public function clearCache() { $this->translation->clearCache(); }
/** * Remove the specified resource from storage. * * @param Translation $translation * @return Response */ public function destroy(Translation $translation) { $this->translation->destroy($translation); flash()->success(trans('core::core.messages.resource deleted', ['name' => trans('translation::translations.title.translations')])); return redirect()->route('admin.translation.translation.index'); }
public function update(TranslationTranslation $translationTranslation, Request $request) { $this->translation->updateTranslationToValue($translationTranslation, $request->get('oldValue')); return redirect()->route('admin.translation.translation.index')->withSuccess('Translation saved.'); }