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.

OpenTTD vs Simutrans
Saját közlekedési szimuláció létrehozása szórakoztató, pihentető és rendkívül csábító lehet. Ezért meg kell győződnie arról, hogy a lehető legtöbb ját...
OpenTTD bemutató
Az OpenTTD az egyik legnépszerűbb üzleti szimulációs játék. Ebben a játékban létre kell hoznia egy csodálatos szállítási vállalkozást. Azonban kezdete...
SuperTuxKart Linuxhoz
A SuperTuxKart egy nagyszerű cím, amelynek célja, hogy ingyenesen hozza el a Mario Kart élményét Linux rendszerén. Elég kihívást jelentő és szórakozta...