laravel

Determining if a Translation Exists

Determining if a Translation Exists

Problem

You want to determine if a translation exists for a particular key.

Solution

Use the Lang::has() method.

To check if a translation exists for the current locale pass a single argument to the method. The argument is the key you're checking.

if (Lang::has('message.welcome'))

echo "The welcome message translation exists for the current locale";

Discussion

You can specify the locale to check with the second argument.

if (Lang::has('message.welcome', 'es'))

echo "The welcome message translation exists for Spanish";

If the second argument isn't used then the current locale is used.

AppyMouse na tela Trackpad e ponteiro do mouse para tablets Windows
Os usuários de tablets costumam perder o ponteiro do mouse, especialmente quando costumam usar laptops. Os smartphones e tablets touchscreen vêm com m...
O botão do meio do mouse não funciona no Windows 10
O botão do meio do mouse ajuda você a percorrer longas páginas da web e telas com muitos dados. Se isso parar, você vai acabar usando o teclado para r...
Como alterar os botões esquerdo e direito do mouse no PC com Windows 10
É normal que todos os dispositivos de mouse de computador sejam ergonomicamente projetados para usuários destros. Mas existem dispositivos de mouse di...