ManagesTranslations.php 771B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Illuminate\View\Concerns;
  3. trait ManagesTranslations
  4. {
  5. /**
  6. * The translation replacements for the translation being rendered.
  7. *
  8. * @var array
  9. */
  10. protected $translationReplacements = [];
  11. /**
  12. * Start a translation block.
  13. *
  14. * @param array $replacements
  15. * @return void
  16. */
  17. public function startTranslation($replacements = [])
  18. {
  19. ob_start();
  20. $this->translationReplacements = $replacements;
  21. }
  22. /**
  23. * Render the current translation.
  24. *
  25. * @return string
  26. */
  27. public function renderTranslation()
  28. {
  29. return $this->container->make('translator')->getFromJson(
  30. trim(ob_get_clean()), $this->translationReplacements
  31. );
  32. }
  33. }