src/Translator.php
public function get($key, array $replace = array(), $locale = null, $fallback = true, $useDB = null)
    {
        $inplaceEditMode = $this->manager->config('inplace_edit_mode');
        list($namespace, $group, $item) = $this->parseKey($key);

        if ($this->inPlaceEditing() && $inplaceEditMode == 2) {
            if (!in_array($key, $this->usedKeys)) {
                $this->usedKeys[] = $key;
            }
        }

        if (!$this->suspendInPlaceEdit && $this->inPlaceEditing() && $inplaceEditMode == 1) {
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            return $this->inPlaceEditLink(null, true, $key, $locale);
        }

        if ($useDB === null) $useDB = $this->useDB;

        if ($useDB && $useDB !== 2) {
            $augmentedGroup = $this->manager->getAugmentedGroup($namespace, $group);
            $result = $this->manager->cachedTranslation('', $augmentedGroup, $item, $locale ?: $this->locale());
            if ($result) {
                $this->notifyUsingGroupItem('', $augmentedGroup, $item, $locale);
                return $this->processResult($result, $replace);
            }
        }

        if ($useDB == 2) {
            if ($this->manager && $group && $item && !$this->manager->excludedPageEditGroup($group)) {
                $t = $this->manager->missingKey($namespace, $group, $item, $locale, $this->isUseLottery(), true);
                if ($t) {
                    $result = $t->value ?: $key;
                    if ($t->isDirty()) {
                        unset($t->diff); // remove value added by inplaceedit link
                        $t->save();
                    }
                    $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
                    return $this->processResult($result, $replace);
                }
            }
        }

        $result = parent::get($key, $replace, $locale, $fallback);
        if ($result === $key) {
            if ($useDB === 1) {
                if ($this->manager && $group && $item && !$this->manager->excludedPageEditGroup($group)) {
                    $t = $this->manager->missingKey($namespace, $group, $item, $locale, $this->isUseLottery(), true);
                    if ($t) {
                        $result = $t->saved_value ?: $key;
                        if ($t->isDirty()) {
                            unset($t->diff); // remove value added by inplaceedit link
                            $t->save();
                        }

                        // save in cache even if it has no value to prevent hitting the database every time just to figure it out
                        if (true || $result !== $key) {
                            // save in cache
                            $this->manager->cacheTranslation($namespace, $group, $item, $result, $locale ?: $this->getLocale());
                            return $this->processResult($result, $replace);
                        }
                        $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
                        return $result;
                    }
                }
            }

            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
        } else {
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            return $this->processResult($result, $replace);
        }
        return $result;
    }
public function get($key, array $replace = array(), $locale = null, $fallback = true, $useDB = null)
    {
        $inplaceEditMode = $this->manager->config('inplace_edit_mode');
        list($namespace, $group, $item) = $this->parseKey($key);

        if ($this->inPlaceEditing() && $inplaceEditMode == 2) {
            if (!in_array($key, $this->usedKeys)) {
                $this->usedKeys[] = $key;
            }
        }

        if (!$this->suspendInPlaceEdit && $this->inPlaceEditing() && $inplaceEditMode == 1) {
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            return $this->inPlaceEditLink(null, true, $key, $locale);
        }

        if ($useDB === null) $useDB = $this->useDB;

        if ($useDB && $useDB !== 2) {
            $augmentedGroup = $this->manager->getAugmentedGroup($namespace, $group);
            $result = $this->manager->cachedTranslation('', $augmentedGroup, $item, $locale ?: $this->locale());
            if ($result) {
                $this->notifyUsingGroupItem('', $augmentedGroup, $item, $locale);
                return $this->processResult($result, $replace);
            }
        }

        if ($useDB == 2) {
            if ($this->manager && $group && $item && !$this->manager->excludedPageEditGroup($group)) {
                $t = $this->manager->missingKey($namespace, $group, $item, $locale, $this->isUseLottery(), true);
                if ($t) {
                    $result = $t->value ?: $key;
                    if ($t->isDirty()) {
                        unset($t->diff); // remove value added by inplaceedit link
                        $t->save();
                    }
                    $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
                    return $this->processResult($result, $replace);
                }
            }
        }

        $result = parent::get($key, $replace, $locale, $fallback);
        if ($result === $key) {
            if ($useDB === 1) {
                if ($this->manager && $group && $item && !$this->manager->excludedPageEditGroup($group)) {
                    $t = $this->manager->missingKey($namespace, $group, $item, $locale, $this->isUseLottery(), true);
                    if ($t) {
                        $result = $t->saved_value ?: $key;
                        if ($t->isDirty()) {
                            unset($t->diff); // remove value added by inplaceedit link
                            $t->save();
                        }

                        // save in cache even if it has no value to prevent hitting the database every time just to figure it out
                        if (true || $result !== $key) {
                            // save in cache
                            $this->manager->cacheTranslation($namespace, $group, $item, $result, $locale ?: $this->getLocale());
                            return $this->processResult($result, $replace);
                        }
                        $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
                        return $result;
                    }
                }
            }

            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
        } else {
            $this->notifyUsingGroupItem($namespace, $group, $item, $locale);
            return $this->processResult($result, $replace);
        }
        return $result;
    }
Get the translation for the given key.

@param  string $key
@param  array $replace
@param  string $locale
@param bool $fallback
@param  int $useDB null - check usedb field which is set to 1 by default,
0 - don't use,
1 - only if key is missing in files or saved in the translator cache, use saved_value
fallback on $key,
2 - always use value from db, (unpublished value) not cached.

@return string