diff --git a/formwork/src/Languages/Languages.php b/formwork/src/Languages/Languages.php index 236db79f..c0763c61 100644 --- a/formwork/src/Languages/Languages.php +++ b/formwork/src/Languages/Languages.php @@ -3,6 +3,7 @@ namespace Formwork\Languages; use Formwork\Core\Formwork; +use Formwork\Translations\Translation; use Formwork\Utils\HTTPNegotiation; class Languages @@ -99,6 +100,15 @@ class Languages return $this->current === $this->default; } + /** + * Get the translation for the current language or the fallback one + */ + public function getTranslation(): Translation + { + $fallback = Formwork::instance()->config()->get('translations.fallback'); + return Formwork::instance()->translations()->get($this->current ?? $fallback, true); + } + /** * Create a Languages instance from a given request */