mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-29 11:31:19 +01:00
Add Languages::getTranslation()
This commit is contained in:
parent
37fe4d482f
commit
943c0bb1f2
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user