public function getTermId($title, $vocabulary_id, $language_id = null, $type = 0)
    {
        $title = trim($title);
        if ($title == '') {
            return false;
        }

        if (!is_numeric($vocabulary_id)) {
            $vocabulary_id = $this->vocabulary($vocabulary_id);
        }

        $language_id = $this->getLanguage($vocabulary_id, $language_id);

        $search = $this->searchTerm($title, $vocabulary_id, $language_id);
        if ($search !== null) {
            return $search;
        }

        // Add term
        $term = new TermContainer(['vocabulary_id' => $vocabulary_id]);

        if ($type !== 0) {
            $term->type = $type;
        }
        $term->save();

        // Add translation
        $translation = [
            'language_id' => $language_id,
            'title' => $title,
        ];
        $term->translations()->save(new TermData($translation));

        return $term->id;
    }