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.

Sådan installeres og afspilles Doom på Linux
Introduktion til undergang Doom-serien opstod i 90'erne efter frigivelsen af ​​den originale Doom. Det var et øjeblikkeligt hit, og fra den tid af har...
Vulkan til Linux-brugere
Med hver nye generation af grafikkort ser vi spiludviklere skubbe grænserne for grafisk troskab og komme et skridt tættere på fotorealisme. Men på tro...
OpenTTD vs Simutrans
Oprettelse af din egen transportsimulering kan være sjovt, afslappende og ekstremt lokkende. Derfor skal du sørge for at prøve så mange spil som mulig...