public function getTranslatedTerm($termId, $taxName)
 {
     $tree = Tree::grow($termId, "Term");
     if ($tree->isLocalized()) {
         $translationEntity = $tree->getLocalizationIn($this);
         if ($translationEntity) {
             return $translationEntity->getWordpressObject();
         }
         if ($this->isDefault()) {
             return get_term_by('id', $tree->getRootId(), $taxName);
         }
     }
 }
 public function generatePermalink($permalink, $postId)
 {
     $postId = is_object($postId) ? $mixed->ID : $postId;
     if (wp_is_post_revision($postId)) {
         return $this->addLocaleHomeUrl($permalink);
     }
     $postAttempingToTranslate = get_post($postId);
     if (!$postAttempingToTranslate) {
         return $this->addLocaleHomeUrl($permalink);
     }
     // Translate the current post_name.
     $tree = Tree::grow($postAttempingToTranslate->ID, "WP_Post");
     if ($tree->isLocalized()) {
         $permalink = $this->translatePostName($postAttempingToTranslate, $permalink);
     }
     if ($this->currentLocale->hasPostTranslation($postAttempingToTranslate->ID)) {
         // Translate up the tree should the post have parents.
         $generationPointer = $postAttempingToTranslate;
         while ($generationPointer && (int) $generationPointer->post_parent > 0) {
             $parent = get_post($generationPointer->post_parent);
             $parentTree = Tree::grow($parent->ID, "WP_Post");
             if ($parentTree->isLocalized($parent->ID)) {
                 $permalink = $this->translatePostName($parent, $permalink);
                 $generationPointer = $parent;
             }
         }
         // Home urls should not display the post_name slug on translated versions.
         if (!$this->currentLocale->isDefault()) {
             $homepageId = Strata::i18n()->query()->getDefaultHomepageId();
             $tree = Tree::grow($homepageId, "WP_Post");
             $localizedHomePage = $tree->getLocalizationIn($this->currentLocale);
             if ($localizedHomePage && (int) $postAttempingToTranslate->ID === (int) $localizedHomePage->getObjectId()) {
                 $permalink = Utility::replaceFirstOccurence($localizedHomePage->getWordpressObject()->post_name . "/", "", $permalink);
             }
         }
     }
     // Translate the default Wordpress custom post type slug
     $model = $this->getStrataModel($postAttempingToTranslate);
     if (!is_null($model)) {
         $permalink = $this->localizeDefaultSlug($model, $permalink);
     }
     return $this->addLocaleHomeUrl($permalink);
 }
 /**
  * [setLocaleByTaxonomyId description]
  * @param int $taxonomyId
  * @param string $taxonomyType
  * @return \Strata\i18n\Locale
  */
 private function getLocaleByTaxonomyId($taxonomyId, $taxonomyType)
 {
     $tree = Tree::grow($taxonomyId, "Term");
     if ($tree->isLocalized()) {
         return $tree->getLocalizationLocaleById($taxonomyId);
     }
 }