Return True if the translation exists for this slug.
332286
def translation_exists(self, slug, lang):
        """"""

        try:
            return translations.Translation.get(
                project_slug=self.get_project_slug(lang),
                slug=slug,
                lang=lang,
            )

        except (NotFoundError, RemoteServerError):
            pass

        return False
981643
def get_translator (domain, directory, languages=None,
                    translatorklass=Translator, fallback=False,
                    fallbackklass=NullTranslator):
    """"""
    translator = gettext.translation(domain, localedir=directory,
            languages=languages, class_=translatorklass, fallback=fallback)
    if not isinstance(translator, gettext.GNUTranslations) and fallbackklass:
        translator = fallbackklass()
    return translator
60453
def get_complete_slug(self, language=None, hideroot=True):
        """"""
        if not language:
            language = settings.PAGE_DEFAULT_LANGUAGE

        if self._complete_slug and language in self._complete_slug:
            return self._complete_slug[language]

        self._complete_slug = cache.get(self.PAGE_URL_KEY % (self.pk))
        if self._complete_slug is None:
            self._complete_slug = {}
        elif language in self._complete_slug:
            return self._complete_slug[language]

        if hideroot and settings.PAGE_HIDE_ROOT_SLUG and self.is_first_root():
            url = ''
        else:
            url = '%s' % self.slug(language)

        key = self.ANCESTORS_KEY % self.pk
        ancestors = cache.get(key, None)
        if ancestors is None:
            ancestors = self.get_ancestors(ascending=True)
            cache.set(key, ancestors)

        for ancestor in ancestors:
            url = ancestor.slug(language) + '/' + url

        self._complete_slug[language] = url
        cache.set(self.PAGE_URL_KEY % (self.pk), self._complete_slug)
        return url
1258635
public function hasDataInPostsType()
    {
        $postTypes = PostType::all();
        foreach($postTypes as $postType){
            $hasData = DB::table($postType->slug)->where("createdByUserID", $this->userID)->count();
            if($hasData) {
                return true;
            }

            foreach($postType->fields as $field){
                if($field->type->inputType == "db" && $field->dbTable->name == "users") {
                    if($field->translatable) {
                        if($field->isMultiple) {
                            foreach(Language::all() as $language){
                                $hasData = DB::table("post_articles")->whereRaw("JSON_CONTAINS($field->slug->\"$.$language->slug\", '[$this->userID]')")->count();
                                if($hasData) { return true;
                                }
                            }
                        }else{
                            foreach(Language::all() as $language){
                                $hasData = DB::table($postType->slug)->where($field->slug."->".$language->slug, $this->userID)->count();
                                if($hasData) { return true;
                                }
                            }
                        }
                    }else{
                        if($field->isMultiple) {
                            $hasData = DB::table($postType->slug)->whereRaw("JSON_CONTAINS($field->slug, '[$this->userID]')")->count();
                            if($hasData) { return true;
                            }
                        }else{
                            $hasData = DB::table($postType->slug)->where($field->slug, $this->userID)->count();
                            if($hasData) { return true;
                            }
                        }
                    }
                }

            }

        }
        return false;
    }
1334214
def _save_translations(sender, instance, *args, **kwargs):
	
	
	# If we are in a site with one language there is no need of saving translations
	if site_is_monolingual():
		return False

	cls = sender

	# If its class has no "translatable_fields" then there are no translations
	if not hasattr(cls._meta, "translatable_fields"):
		return False

	# For each translatable field, get its value, computes its md5 and for each language creates its
	# empty translation.
	for field in cls._meta.translatable_fields:
		value = getattr(instance,field)
		if not value is None:
			md5_value = checksum(value)
			setattr( instance, u"md5"+field, md5_value )
			for lang in settings.LANGUAGES:
				lang = lang[0]
				# print "({0}!={1}) = {2}".format(lang, settings.LANGUAGE_CODE,lang!=settings.LANGUAGE_CODE)
				if lang != settings.LANGUAGE_CODE:
					context = u"Updating from object"
					if hasattr(instance, "trans_context"):
						context = getattr(instance, "trans_context")
					trans = FieldTranslation.update(instance, field, lang, context)
1194600
def get_complete_slug(self, language=None, hideroot=True):
        """"""
        if not language:
            language = settings.PAGE_DEFAULT_LANGUAGE

        if self._complete_slug and language in self._complete_slug:
            return self._complete_slug[language]

        self._complete_slug = cache.get(self.PAGE_URL_KEY % (self.id))
        if self._complete_slug is None:
            self._complete_slug = {}
        elif language in self._complete_slug:
            return self._complete_slug[language]

        if hideroot and settings.PAGE_HIDE_ROOT_SLUG and self.is_first_root():
            url = u''
        else:
            url = u'%s' % self.slug(language)
        for ancestor in self.get_ancestors(ascending=True):
            url = ancestor.slug(language) + u'/' + url

        self._complete_slug[language] = url
        cache.set(self.PAGE_URL_KEY % (self.id), self._complete_slug)
        return url
419485
public static function checkBySlug(string $slug)
    {
        if(Language::all()->where('slug', $slug)->count()) {
            return true;
        }
        return false;
    }
1163924
def slug(self, language=None, fallback=True):
        

        slug = self.get_content(language, 'slug', language_fallback=fallback)
        if slug == '':
            return "Page {0}".format(self.pk)

        return slug
746891
private function isSlugUnique($slug, $entityClass, $entityId, array $similarSlugs)
    {
        if (empty($similarSlugs)) {
            return true;
        }
        foreach ($similarSlugs as $similar) {
            if ($slug !== $similar['slug']) {
                continue;
            }
            if (empty($entityId)) {
                return false;
            }
            if (!($entityId == $similar['object_id']
                && ($entityClass === $similar['object_class'] || in_array($similar['object_class'], class_parents($entityClass))))
            ) {
                return false;
            }
        }

        return true;
    }
223587
public function t() {
        $args = func_get_args();
        if(count($args) < 1) {
            return false;
        }

        $message = array_shift($args);

        if(!isset($this->messages[$message])) {
	        // No translation available, return original string
            return vsprintf($message, $args);
        }

		$translation = $this->messages[$message];
        if(is_array($translation)) {
        	// Variations found, pick a translation by random
        	$translation = $translation[array_rand($translation)];
        }

        // Return translation with optional replacements
        return vsprintf($translation, $args);
    }
1314403
def slug_exists(self, request):
        
        if not request.user.is_authenticated:
            return Response(status=status.HTTP_401_UNAUTHORIZED)

        if 'name' not in request.query_params:
            return Response({'error': 'Query parameter `name` must be given.'},
                            status=status.HTTP_400_BAD_REQUEST)

        queryset = self.get_queryset()
        slug_name = request.query_params['name']
        return Response(queryset.filter(slug__iexact=slug_name).exists())
1023277
protected function hasLocalizedVersion()
    {
        if ((bool)$this->getConfig("use_localized_views") && Strata::i18n()->hasActiveLocales()) {
            $localizedFilename =  $this->generateLocalizedViewPath();
            return file_exists($localizedFilename . $this->getConfig('file_extention'));
        }

        return false;
    }
530416
def can_be_(self, state):
    """"""
    translator = self._meta['translator']
    state = translator.translate(state)

    if self._meta['complete']:
        return True

    if self.actual_state is None:
        return True

    transitions = self._meta['transitions'][self.actual_state]
    return state in transitions
773728
def _is_lang_change(self, request):
        """"""
        if 'lang' not in request.GET:
            return False

        return not any(request.path.endswith(url) for url in self.exempt_urls)
985586
def has(self, lang, instance):
        
        instance_key = TransCache._create_key(lang, instance)
        return instance_key in self.cache
778563
def key_exists?(key, locale)
      I18n.locale = locale
      I18n.translate(key, raise: true)
      return true
    rescue I18n::MissingInterpolationArgument
      return true
    rescue I18n::MissingTranslationData
      return false
    end
1025578
def with_translations(self, **kwargs):
        

        force = kwargs.pop("force", False)

        if self._prefetch_translations_done and force is False:
            return self

        self._prefetched_translations_cache = utils.get_grouped_translations(
            self, **kwargs
        )
        self._prefetch_translations_done = True

        return self._clone()