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.

Trackpad a ukazatel myši AppyMouse na obrazovce pro tablety Windows
Uživatelé tabletů často postrádají ukazatel myši, zejména když obvykle používají notebooky. Dotykové smartphony a tablety mají mnoho výhod a jediným o...
Střední tlačítko myši nefunguje ve Windows 10
The prostřední tlačítko myši pomáhá procházet dlouhé webové stránky a obrazovky se spoustou dat. Pokud se to zastaví, budete nakonec používat klávesni...
Jak změnit levé a pravé tlačítko myši na počítači se systémem Windows 10
Je úplnou normou, že všechna zařízení počítačových myší jsou ergonomicky navržena pro praváky. K dispozici jsou však myší zařízení, která jsou speciál...