src/Manager.php
public function missingKey($namespace, $group, $key, $locale = null, $useLottery = true, $findOrNew = false)
    {
        if (!$useLottery || $this->config(self::LOG_MISSING_KEYS_KEY)) {
            // L5 changes
            $group = self::fixGroup($group);
            $group = $namespace && $namespace !== '*' ? $namespace . '::' . $group : $group;
            if (!in_array($group, $this->config(self::EXCLUDE_GROUPS_KEY))) {
                $lottery = 1;
                if ($useLottery && $this->config(self::MISSING_KEYS_LOTTERY_KEY) !== 1) {
                    $lottery = \Session::get($this->config(self::PERSISTENT_PREFIX_KEY) . self::LOTTERY_PERSISTENT_SUFFIX, '');
                    if ($lottery === '') {
                        $lottery = rand(1, $this->config(self::MISSING_KEYS_LOTTERY_KEY));
                        \Session::put($this->config(self::PERSISTENT_PREFIX_KEY) . self::LOTTERY_PERSISTENT_SUFFIX, $lottery);
                    }
                }

                if ($lottery == 1) {
                    // here need to map a local group to wbn: or vnd: package if the local file does not already exist so that
                    // new keys will be added to the appropriate package
                    $augmentedGroupList = $this->getGroupAugmentedList();
                    $augmentedGroup = $group;
                    if (array_key_exists($group, $augmentedGroupList)) {
                        $augmentedGroup = $augmentedGroupList[$group];
                    }

                    $locale = $locale ?: ($this->translator ?: ($this->translator = $this->app->make('translator')))->getLocale();

                    if ($findOrNew) {
                        $translation = $this->firstOrNewTranslation(array(
                            'locale' => $locale,
                            'group' => $augmentedGroup,
                            'key' => $key,
                        ));
                    } else {
                        $translation = $this->firstOrCreateTranslation(array(
                            'locale' => $locale,
                            'group' => $augmentedGroup,
                            'key' => $key,
                        ));
                    }

                    if ($group === 'JSON' && $locale !== 'json') {
                        // we create a key if one does not exist since we know what the json key's value should be

                        if (!$this->isWebUI) {
                            $this->loadLtmJsonKeys(false);
                            if (!array_key_exists($key, $this->jsonLtmKeys)) {
                                $ltmKey = $this->generateLtmKey($this->jsonLtmKeys, $key);

                                $jsonTranslation = $this->firstOrCreateTranslation(array(
                                    'locale' => 'json',
                                    'group' => $augmentedGroup,
                                    'key' => $ltmKey,
                                    'value' => $key,
                                    'saved_value' => $key,
                                    'status' => Translation::STATUS_CHANGED,
                                ));

                                $this->ltmJsonKeys[$ltmKey] = $key;
                                $this->jsonLtmKeys[$key] = $ltmKey;
                            }
                            //                        } else if ($this->createJsonKeysForWebUI) {
                            //                            $this->loadLtmJsonKeys(false);
                            //                            if (!array_key_exists($key, $this->ltmJsonKeys)) {
                            //                                $ltmKey = $key;
                            //
                            //                                $jsonTranslation = $this->firstOrCreateTranslation(array(
                            //                                    'locale' => 'json',
                            //                                    'group' => $augmentedGroup,
                            //                                    'key' => $ltmKey,
                            //                                    'value' => $key,
                            //                                    'saved_value' => $key,
                            //                                    'status' => Translation::STATUS_CHANGED,
                            //                                ));
                            //
                            //                                $this->ltmJsonKeys[$ltmKey] = $key;
                            //                                $this->jsonLtmKeys[$key] = $ltmKey;
                            //                            }
                        }
                    }

                    /* @var $translation \Vsch\TranslationManager\Models\Translation */
                    return $translation;
                }
            }
        }
        return null;
    }
public function missingKey($namespace, $group, $key, $locale = null, $useLottery = true, $findOrNew = false)
    {
        if (!$useLottery || $this->config(self::LOG_MISSING_KEYS_KEY)) {
            // L5 changes
            $group = self::fixGroup($group);
            $group = $namespace && $namespace !== '*' ? $namespace . '::' . $group : $group;
            if (!in_array($group, $this->config(self::EXCLUDE_GROUPS_KEY))) {
                $lottery = 1;
                if ($useLottery && $this->config(self::MISSING_KEYS_LOTTERY_KEY) !== 1) {
                    $lottery = \Session::get($this->config(self::PERSISTENT_PREFIX_KEY) . self::LOTTERY_PERSISTENT_SUFFIX, '');
                    if ($lottery === '') {
                        $lottery = rand(1, $this->config(self::MISSING_KEYS_LOTTERY_KEY));
                        \Session::put($this->config(self::PERSISTENT_PREFIX_KEY) . self::LOTTERY_PERSISTENT_SUFFIX, $lottery);
                    }
                }

                if ($lottery == 1) {
                    // here need to map a local group to wbn: or vnd: package if the local file does not already exist so that
                    // new keys will be added to the appropriate package
                    $augmentedGroupList = $this->getGroupAugmentedList();
                    $augmentedGroup = $group;
                    if (array_key_exists($group, $augmentedGroupList)) {
                        $augmentedGroup = $augmentedGroupList[$group];
                    }

                    $locale = $locale ?: ($this->translator ?: ($this->translator = $this->app->make('translator')))->getLocale();

                    if ($findOrNew) {
                        $translation = $this->firstOrNewTranslation(array(
                            'locale' => $locale,
                            'group' => $augmentedGroup,
                            'key' => $key,
                        ));
                    } else {
                        $translation = $this->firstOrCreateTranslation(array(
                            'locale' => $locale,
                            'group' => $augmentedGroup,
                            'key' => $key,
                        ));
                    }

                    if ($group === 'JSON' && $locale !== 'json') {
                        // we create a key if one does not exist since we know what the json key's value should be

                        if (!$this->isWebUI) {
                            $this->loadLtmJsonKeys(false);
                            if (!array_key_exists($key, $this->jsonLtmKeys)) {
                                $ltmKey = $this->generateLtmKey($this->jsonLtmKeys, $key);

                                $jsonTranslation = $this->firstOrCreateTranslation(array(
                                    'locale' => 'json',
                                    'group' => $augmentedGroup,
                                    'key' => $ltmKey,
                                    'value' => $key,
                                    'saved_value' => $key,
                                    'status' => Translation::STATUS_CHANGED,
                                ));

                                $this->ltmJsonKeys[$ltmKey] = $key;
                                $this->jsonLtmKeys[$key] = $ltmKey;
                            }
                            //                        } else if ($this->createJsonKeysForWebUI) {
                            //                            $this->loadLtmJsonKeys(false);
                            //                            if (!array_key_exists($key, $this->ltmJsonKeys)) {
                            //                                $ltmKey = $key;
                            //
                            //                                $jsonTranslation = $this->firstOrCreateTranslation(array(
                            //                                    'locale' => 'json',
                            //                                    'group' => $augmentedGroup,
                            //                                    'key' => $ltmKey,
                            //                                    'value' => $key,
                            //                                    'saved_value' => $key,
                            //                                    'status' => Translation::STATUS_CHANGED,
                            //                                ));
                            //
                            //                                $this->ltmJsonKeys[$ltmKey] = $key;
                            //                                $this->jsonLtmKeys[$key] = $ltmKey;
                            //                            }
                        }
                    }

                    /* @var $translation \Vsch\TranslationManager\Models\Translation */
                    return $translation;
                }
            }
        }
        return null;
    }
@param             $namespace string
@param             $group     string
@param             $key       string
@param null|string $locale
@param bool $useLottery
@param bool $findOrNew

@return \Vsch\TranslationManager\Models\Translation|null