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.

Gry Top 10 Games to Play on Ubuntu
Top 10 Games to Play on Ubuntu
Windows platform has been one of the dominating platforms for gaming because of the huge percentage of games that are developing today to natively sup...
Gry 5 najlepszych gier zręcznościowych dla systemu Linux
5 najlepszych gier zręcznościowych dla systemu Linux
W dzisiejszych czasach komputery to poważne maszyny używane do gier. Jeśli nie możesz uzyskać nowego wysokiego wyniku, będziesz wiedział, o co mi chod...
Gry Bitwa o Wesnoth 1.13.6 Wydanie rozwojowe
Bitwa o Wesnoth 1.13.6 Wydanie rozwojowe
Bitwa o Wesnoth 1.13.6 wydana w zeszłym miesiącu jest szóstą wersją rozwojową w 1.13.Seria x i zapewnia szereg ulepszeń, w szczególności w interfejsie...