gets how much complete translation of category is in a certain language
15842
def complete_percentage_in(lang)
      if self.keys.blank?
        100
      else
        accepted_keys = accepted_keys(lang)
        100 * accepted_keys.count / self.keys.count
      end
    end
558019
def extract_translations(self, string):
        """"""

        trans = []
        for t in Lexer(string.decode("utf-8"), None).tokenize():
            if t.token_type == TOKEN_BLOCK:
                if not t.contents.startswith(
                        (self.tranz_tag, self.tranzchoice_tag)):
                    continue

                is_tranzchoice = t.contents.startswith(
                    self.tranzchoice_tag +
                    " ")
                kwargs = {
                    "id": self._match_to_transvar(id_re, t.contents),
                    "number": self._match_to_transvar(number_re, t.contents),
                    "domain": self._match_to_transvar(domain_re, t.contents),
                    "locale": self._match_to_transvar(locale_re, t.contents),
                    "is_transchoice": is_tranzchoice, "parameters": TransVar(
                        [x.split("=")[0].strip() for x in properties_re.findall(t.contents) if x],
                        TransVar.LITERAL
                    ),
                    "lineno": t.lineno,
                }

                trans.append(Translation(**kwargs))
        return trans
1091010
public function totalChildren(): string
    {
        $total = (int) DB::table('families')
            ->where('f_file', '=', $this->tree->id())
            ->sum('f_numchil');

        return I18N::number($total);
    }
78916
public function getCategoriesPlain() : Collection
    {
        static $categories;

        if ($categories) {
            return $categories;
        }

        $categories = [];
        $languages = TransHelper::getAllLanguages();

        foreach (Category::all() as $category) {
            $categoryData = [
                'id'        => $category->id,
                'parent_id' => $category->parent_id,
                'slugs'     => [],
            ];

            foreach ($languages as $language) {
                $translation = $category->translations->where('locale', $language->iso_code)->first();
                $slug = object_get($translation, 'slug');

                $categoryData['slugs'][$language->iso_code] = $slug;
            }

            $categories[] = $categoryData;
        }

        $categories = collect($categories);

        return $categories;
    }
66832
public function getAvailableInLangs()
    {
        $languages = \OxidEsales\Eshop\Core\Registry::getLang()->getLanguageNames();

        $objFields = $this->_getTableFields(
            getViewName($this->_sCoreTable, -1, -1),
            true
        );
        $multiLangFields = [];

        //selecting all object multilang fields
        foreach ($objFields as $key => $value) {
            //skipping oxactive field
            if (preg_match('/^oxactive(_(\d{1,2}))?$/', $key)) {
                continue;
            }

            $fieldLang = $this->_getFieldLang($key);

            //checking, if field is multilanguage
            if ($this->isMultilingualField($key) || $fieldLang > 0) {
                $newKey = preg_replace('/_(\d{1,2})$/', '', $key);
                $multiLangFields[$newKey][] = (int) $fieldLang;
            }
        }

        // if no multilanguage fields, return default languages array
        if (count($multiLangFields) < 1) {
            return $languages;
        }

        // select from non-multilanguage core view (all ml tables joined to one)
        $db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
        $query = "select * from " . getViewName($this->_sCoreTable, -1, -1) . " where oxid = " . $db->quote($this->getId());
        $rs = $db->getAll($query);

        $notInLang = $languages;

        // checks if object field data is not empty in all available languages
        // and formats not available in languages array
        if (isset($rs[0]) && is_array($rs[0]) && count($rs[0])) {
            foreach ($multiLangFields as $fieldId => $multiLangIds) {
                foreach ($multiLangIds as $multiLangId) {
                    $fieldName = ($multiLangId == 0) ? $fieldId : $fieldId . '_' . $multiLangId;
                    if ($rs[0][strtoupper($fieldName)]) {
                        unset($notInLang[$multiLangId]);
                        continue;
                    }
                }
            }
        }

        return array_diff($languages, $notInLang);
    }
139845
public function getTranslations( $category = null ) : array
   {

      $translations = [];

      // If no category is defined (must be NULL) return all translations without a
      if ( \is_null( $category ) )
      {

         foreach ( $this->_translations as $identifier => $transData )
         {
            if ( is_string( $transData ) )
            {
               $translations[ $identifier ] = $transData;
               continue;
            }
            if ( ! \is_array( $transData ) || ! isset( $transData[ 'text' ] ) )
            {
               continue;
            }
            $translations[ $identifier ] = $transData[ 'text' ];
         }

         return $translations;

      }

      $category     = \trim( $category );
      $withCategory = \strlen( $category ) > 0;

      $this->getCategories();

      if ( ! \in_array( $category, $this->_categories ) && $category !== '' )
      {
         return $translations;
      }

      foreach ( $this->_translations as $identifier => $transData )
      {

         if ( $withCategory )
         {
            if ( ! \is_array( $transData ) ||
                 ! isset( $transData[ 'category' ] ) ||
                 ! isset( $transData[ 'text' ] ) ||
                 $transData[ 'category' ] !== $category )
            {
               continue;
            }
            $translations[ $identifier ] = $transData[ 'text' ];
         }
         else
         {
            if ( \is_array( $transData ) && isset( $transData[ 'text' ] ) )
            {
               if ( ( isset( $transData[ 'category' ] ) && $transData[ 'category' ] === '' ) ||
                    ! isset( $transData[ 'category' ] ) )
               {
                  $translations[ $identifier ] = $transData[ 'text' ];
               }
            }
            else if ( \is_string( $transData ) )
            {
               $translations[ $identifier ] = $transData;
            }
         }

      }

      return $translations;

   }
372542
def translations
      if params[:sort_by] == 'votes'
        @translations = @translation_key.translations.in(session[:lang_to]).sorted_by_votes
      else
        @translations = @translation_key.translations.in(session[:lang_to]).order('created_at DESC')
      end
      respond_to do |format|
        format.js
      end
    end
389257
public function getAvailable()
    {
        $languagesArray = $this->languages; //Make local copy

        $languagesArray = array_map(function($value) {
            return preg_quote($value);
        }, $languagesArray);

        sort($languagesArray);

        return implode('|', array_reverse($languagesArray));
    }
304184
def get_truncation_language() -> ParserElement:
    """"""
    l1 = truncation_tag + nest(amino_acid(AMINO_ACID) + ppc.integer(TRUNCATION_POSITION))
    l1.setParseAction(_handle_trunc)
    l2 = truncation_tag + nest(ppc.integer(TRUNCATION_POSITION))
    l2.setParseAction(_handle_trunc_legacy)
    return l1 | l2
1354591
def get_language_details(self, language):
        """"""
        for lang in self.user_data.languages:
            if language == lang['language_string']:
                return lang

        return {}
1313478
def summary(self) -> str:
        
        if not self.translations:
            self.update()
        return summary.metar(self.translations)
725880
def get_jokes(language='en', category='neutral'):
    

    if language not in all_jokes:
        raise LanguageNotFoundError('No such language %s' % language)

    jokes = all_jokes[language]

    if category not in jokes:
        raise CategoryNotFoundError('No such category %s in language %s' % (category, language))

    return jokes[category]
993146
function ( ) {
				_PinCategories = _PinCategories.sort ( 
					function ( a, b ) {
						return a.CategoryName.localeCompare 
						( 
							b.CategoryName,
							_Translator.UserLanguage
						);
					} 
				);
			}
1085101
private function calculateLanguagesPercentage($languages)
    {
        $total = $languages->sum('count');

        return $languages->transform(function ($item) use ($total) {
            return $item + [
                'percentage' => round(($item['count'] / $total) * 100, 2)
            ];
        });
    }
321769
function determineFreqCategories() {
    if (mean - sd < 0) {
      var lowrange = 0 + mean / 3;
    } else {
      var lowrange = mean - sd;
    }
    var midrange = [mean + sd, lowrange];
    var highrange = mean + sd;

    var i = 0;
    for (; i < potentialexamples.length; i++) {
      var word = potentialexamples[i][0];

      if ('undefined' != typeof wordfreq[word.simplified]) {
        pushFrequency(word);
      }
    }

    function pushFrequency(word) {
      if (wordfreq[word.simplified] < lowrange) {
        lowfreq.push(word);
      }
      if (
        wordfreq[word.simplified] >= midrange[1] &&
        wordfreq[word.simplified] < midrange[0]
      ) {
        midfreq.push(word);
      }
      if (wordfreq[word.simplified] >= highrange) {
        highfreq.push(word);
      }
    }
  }
912128
def help_center_category_translations_missing(self, category_id, **kwargs):
        ""
        api_path = "/api/v2/help_center/categories/{category_id}/translations/missing.json"
        api_path = api_path.format(category_id=category_id)
        return self.call(api_path, **kwargs)
667428
protected function validateDescriptionCategory()
    {
        $fields = array(
            'description_1' => $this->translation->text('First description'),
            'description_2' => $this->translation->text('Second description')
        );

        $errors = 0;
        foreach ($fields as $field => $label) {
            $value = $this->getSubmitted($field);
            if (isset($value) && mb_strlen($value) > 65535) {
                $errors++;
                $this->setErrorLengthRange($field, $label, 0, 65535);
            }
        }

        return empty($errors);
    }