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.

Hry Battle For Wesnoth 1.13.6 Vývoj uvoľnený
Battle For Wesnoth 1.13.6 Vývoj uvoľnený
Battle For Wesnoth 1.13.6 vydané minulý mesiac, je šiestym vývojovým vydaním v 1.13.séria x a prináša množstvo vylepšení, najmä používateľského rozhra...
Hry Ako nainštalovať League Of Legends na Ubuntu 14.04
Ako nainštalovať League Of Legends na Ubuntu 14.04
Ak ste fanúšikom League of Legends, potom je to pre vás príležitosť otestovať spustenie League of Legends. Upozorňujeme, že program PlayOnLinux podpor...
Hry Nainštalujte si najnovšiu strategickú hru OpenRA na Ubuntu Linux
Nainštalujte si najnovšiu strategickú hru OpenRA na Ubuntu Linux
OpenRA je herný engine Libre / Free Real Time Strategy, ktorý obnovuje rané hry z Westwoodu, ako napríklad klasické Command & Conquer: Red Alert. Dist...