Fetch the inline translations
172998
def _get_inline_translations(self, request, language_code, obj=None):
        
        inline_instances = self.get_inline_instances(request, obj=obj)
        for inline in inline_instances:
            if issubclass(inline.model, TranslatableModelMixin):
                # leverage inlineformset_factory() to find the ForeignKey.
                # This also resolves the fk_name if it's set.
                fk = inline.get_formset(request, obj).fk

                rel_name = 'master__{0}'.format(fk.name)
                filters = {
                    'language_code': language_code,
                    rel_name: obj
                }

                for translations_model in inline.model._parler_meta.get_all_models():
                    qs = translations_model.objects.filter(**filters)
                    if obj is not None:
                        qs = qs.using(obj._state.db)

                    yield inline, qs
153825
def translations(self):
        
        rc = self.reverseComplement().sequence
        for reverseComplemented in False, True:
            for frame in 0, 1, 2:
                seq = rc if reverseComplemented else self.sequence
                # Get the suffix of the sequence for translation. I.e.,
                # skip 0, 1, or 2 initial bases, depending on the frame.
                # Note that this makes a copy of the sequence, which we can
                # then safely append 'N' bases to to adjust its length to
                # be zero mod 3.
                suffix = seq[frame:]
                lengthMod3 = len(suffix) % 3
                if lengthMod3:
                    suffix += ('NN' if lengthMod3 == 1 else 'N')
                yield TranslatedRead(self, translate(suffix), frame,
                                     reverseComplemented)
700173
def get_translation_objects(self, request, language_code, obj=None, inlines=True):
        
        if obj is not None:
            # A single model can hold multiple TranslatedFieldsModel objects.
            # Return them all.
            for translations_model in obj._parler_meta.get_all_models():
                try:
                    translation = translations_model.objects.get(master=obj, language_code=language_code)
                except translations_model.DoesNotExist:
                    continue
                yield [translation]

        if inlines:
            for inline, qs in self._get_inline_translations(request, language_code, obj=obj):
                yield qs
941335
function fetchAttributeTranslations( $asObject = true )
    {
        return eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
                                                    null,
                                                    array( "contentclassattribute_id" => $this->ContentClassAttributeID,
                                                           "contentobject_id" => $this->ContentObjectID,
                                                           "version" => $this->Version ),
                                                    null,
                                                    null,
                                                    $asObject);
    }
425220
def interlink_translated_content(generator):
    '''
    '''
    inspector = GeneratorInspector(generator)
    for content in inspector.all_contents():
        interlink_translations(content)
1260314
def get_aliases(self, lang='en'):
        
        if self.fast_run:
            return list(self.fast_run_container.get_language_data(self.wd_item_id, lang, 'aliases'))

        alias_list = []
        if 'aliases' in self.wd_json_representation and lang in self.wd_json_representation['aliases']:
            for alias in self.wd_json_representation['aliases'][lang]:
                alias_list.append(alias['value'])

        return alias_list
571043
def _get_any_translated_model(self, meta=None):
        
        if meta is None:
            meta = self._parler_meta.root

        tr_model = meta.model
        local_cache = self._translations_cache[tr_model]
        if local_cache:
            # There is already a language available in the case. No need for queries.
            # Give consistent answers if they exist.
            check_languages = [self._current_language] + self.get_fallback_languages()
            try:
                for fallback_lang in check_languages:
                    trans = local_cache.get(fallback_lang, None)
                    if trans and not is_missing(trans):
                        return trans
                return next(t for t in six.itervalues(local_cache) if not is_missing(t))
            except StopIteration:
                pass

        try:
            # Use prefetch if available, otherwise perform separate query.
            prefetch = self._get_prefetched_translations(meta=meta)
            if prefetch is not None:
                translation = prefetch[0]  # Already a list
            else:
                translation = self._get_translated_queryset(meta=meta)[0]
        except IndexError:
            return None
        else:
            local_cache[translation.language_code] = translation
            _cache_translation(translation)
            return translation
519915
private function gatherTranslatableStrings()
    {
        $this->translatables = [];

        $this->scanTwigFiles();
        $this->scanPhpFiles();

        ksort($this->translatables);
    }
158952
def get_inline_expression(self, text):
        """"""
        text = text.strip()
        if not text.startswith(self.inline_tags[0]) or not text.endswith(self.inline_tags[1]):
            return

        return text[2:-2]
1347755
def show_list_translations(context, item):
    
    if not item:
        return

    manager = Manager()
    manager.set_master(item)

    ct_item = ContentType.objects.get_for_model(item)

    item_language_codes = manager.get_languages_from_item(ct_item, item)
    model_language_codes = manager.get_languages_from_model(ct_item.app_label, ct_item.model)

    item_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.filter(code__in=item_language_codes).order_by('name')]

    more_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.exclude(main_language=True).order_by('name')]

    return render_to_string('languages/translation_language_selector.html', {
        'item_languages': item_languages,
        'more_languages': more_languages,
        'api_url': TM_API_URL,
        'app_label': manager.app_label,
        'model': manager.model_label,
        'object_pk': item.pk
    })
589061
def _get_translation(self, lang):
        """"""

        try:
            return self._translations[lang]
        except KeyError:
            # The fact that `fallback=True` is not the default is a serious design flaw.
            rv = self._translations[lang] = gettext.translation(self._domain, localedir=localedir, languages=[lang],
                                                                fallback=True)
            return rv
668524
def fetchall_textdefs(ont):
    
    logging.info("fetching text defs for: "+ont)
    namedGraph = get_named_graph(ont)
    query = """
    prefix IAO: <http://purl.obolibrary.org/obo/IAO_>
    SELECT * WHERE {{
    GRAPH <{g}>  {{
      ?c IAO:0000115 ?d
    }}
    FILTER (!isBlank(?c))
    }}
    """.format(g=namedGraph)
    bindings = run_sparql(query)
    rows = [(r['c']['value'], r['d']['value']) for r in bindings]
    return rows
1006963
def interlink_translations(content):
    '''
    '''
    lang = content.lang
    # sort translations by lang
    content.translations.sort(key=attrgetter('lang'))
    for translation in content.translations:
        relpath = relpath_to_site(lang, translation.lang)
        url = _NATIVE_CONTENT_URL_DB[translation.source_path]
        translation.override_url = posixpath.join(relpath, url)
295525
def lazy_translations(cls):
        """"""
        return {
            cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
            cloudfiles.errors.NoSuchObject: errors.NoObjectException,
        }
438196
function getComputedTranslations(el, property) {
  // The transform being returned by `getComputedStyle` is in the format:
  // `matrix(a, b, c, d, translateX, translateY)` if defined and `none`
  // if the element doesn't have a transform.
  var transform = getComputedStyle(el[0] || el)[property];
  var openIndex = transform.indexOf('(');
  var closeIndex = transform.lastIndexOf(')');
  var output = { x: 0, y: 0 };

  if (openIndex > -1 && closeIndex > -1) {
    var parsedValues = transform
      .substring(openIndex + 1, closeIndex)
      .split(', ')
      .slice(-2);

    output.x = parseInt(parsedValues[0]);
    output.y = parseInt(parsedValues[1]);
  }

  return output;
}
1266081
def all_contents(self):
        ''''''
        translations_iterator = chain(*self.translations_lists())
        return chain(translations_iterator,
                     *(pair[i] for pair in self.contents_list_pairs()
                       for i in (0, 1)))
552942
def get_lines(data_nts, prtfmt=None, nt_fields=None, **kws):
    """"""
    lines = []
    # optional keyword args: prt_if sort_by
    if prtfmt is None:
        prtfmt = mk_fmtfld(data_nts[0], kws.get('joinchr', ' '), kws.get('eol', '\n'))
    # if nt_fields arg is None, use fields from prtfmt string.
    if nt_fields is not None:
        _chk_flds_fmt(nt_fields, prtfmt)
    if 'sort_by' in kws:
        data_nts = sorted(data_nts, key=kws['sort_by'])
    prt_if = kws.get('prt_if', None)
    for data_nt in data_nts:
        if prt_if is None or prt_if(data_nt):
            lines.append(prtfmt.format(**data_nt._asdict()))
    return lines