get translations plus current item, plus original
776676
public function allTranslations()
    {
        $model = '\\'.get_class($this);

        // the translations
        $translations = $this->translations();

        $all_translations = new Collection();
        // the original
        if ($this->translation_of) {
            $original = $model::find($this->translation_of);
            $all_translations = $all_translations->push($original);

            // get all translations from the original
            $translationsOfOriginal = $model::where('translation_of', $original->id)->get();
            foreach($translationsOfOriginal as $translation) {
                $all_translations->push($translation);
            }
        } else {
            // prepend the translation to be first in the list of translations
            $all_translations = $translations->prepend($this);
        }

        return $all_translations;
    }
393196
def translated_value(self):
        
        if self.typeof in self:
            return NATValue(self.get(self.typeof, {}).get(
                'translated_value'))
94108
def _get_translate():
    
    translate = {}
    model_path = pkg_resources.resource_filename('hwrt', 'misc/')
    translation_csv = os.path.join(model_path, 'latex2writemathindex.csv')
    arguments = {'newline': '', 'encoding': 'utf8'}
    with open(translation_csv, 'rt', **arguments) as csvfile:
        contents = csvfile.read()
    lines = contents.split("\n")
    for csvrow in lines:
        csvrow = csvrow.split(',')
        if len(csvrow) == 1:
            writemathid = csvrow[0]
            latex = ""
        else:
            writemathid, latex = csvrow[0], csvrow[1:]
            latex = ','.join(latex)
        translate[latex] = writemathid
    return translate
509341
function(string) {
    var translated = Documentation.TRANSLATIONS[string];
    if (typeof translated == 'undefined')
      return string;
    return (typeof translated == 'string') ? translated : translated[0];
  }
97035
function flattenTranslations(translations) {
  var toReturn = {};

  for (var i in translations) {
    // check if the property is present
    if (!translations.hasOwnProperty(i)) {
      continue;
    } // get the type of the property


    var objType = _typeof(translations[i]); // allow unflattened array of strings


    if (isArray(translations[i])) {
      var count = translations[i].length;

      for (var index = 0; index < count; index++) {
        var itemType = _typeof(translations[i][index]);

        if (itemType !== 'string') {
          console.warn('i18n:', 'currently only arrays of strings are fully supported', translations[i]);
          break;
        }
      }

      toReturn[i] = translations[i];
    } else if (objType == 'object' && objType !== null) {
      var flatObject = flattenTranslations(translations[i]);

      for (var x in flatObject) {
        if (!flatObject.hasOwnProperty(x)) continue;
        toReturn[i + '.' + x] = flatObject[x];
      }
    } else {
      toReturn[i] = translations[i];
    }
  }

  return toReturn;
}
231781
def translate(self):
        """"""
        ident = self.ident
        expr = ex_rvalue(VARIABLE_PREFIX + ident)
        return [expr], set([ident]), set()
191371
function getItemTextContents(element) {
  if (!element[itemTextContentsSymbol]) {
    const items = element.items;
    element[itemTextContentsSymbol] = items.map(child => {
      const text = child.textContent || child.alt;
      return text.toLowerCase();
    });
  }
  return element[itemTextContentsSymbol];
}
926635
def create_translations_for_item_and_its_children(self, item, languages=None):
        

        if not self.master:
            self.set_master(item)

        if not languages:
            languages = self.get_languages()

        result_ids = []

        # first process main object
        fields = self._get_translated_field_names(item)
        tasks = self.create_from_item(languages, item, fields)
        if tasks:
            result_ids += [task.pk for task in tasks]

        # then process child objects from main
        children = self.get_translatable_children(item)
        for child in children:
            fields = self._get_translated_field_names(child)
            tasks = self.create_from_item(languages, child, fields)
            if tasks:
                result_ids += [task.pk for task in tasks]

        return result_ids
1318442
def _read_translations(self):
        
        print('Reading original translations')
        self.translations_map = {}
        n_translations = 0
        with open(os.path.join(self.src_dir, 'translations.txt'),
                  'rb') as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                self.translations_map.setdefault(
                    row['trans_id'], {})[row['lang']] = row['translation']
                n_translations += 1
        print('\ttotal original translations: %s' % n_translations)
840764
def merge(self, other):
        """"""
        if not getattr(other, '_catalog', None):
            return  # NullTranslations() has no _catalog
        if self._catalog is None:
            # Take plural and _info from first catalog found
            self.plural = other.plural
            self._info = other._info.copy()
            self._catalog = other._catalog.copy()
        else:
            self._catalog.update(other._catalog)
552023
def input(self, _in, out, **kwargs):
        """"""
        language_code = _re_language_code.search(_in.read()).group(
            'language_code'
        )
        _in.seek(0)  # move at the begining after matching the language
        catalog = read_po(_in)
        out.write('gettextCatalog.setStrings("{0}", '.format(language_code))
        out.write(json.dumps({
            key: value.string for key, value in catalog._messages.items()
            if key and value.string
        }))
        out.write(');')
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
152987
function _extractTranslation(regexName, regex, content, file, lineNumber, results) {
      var r;
      _log.debug("---------------------------------------------------------------------------------------------------");
      _log.debug('Process extraction with regex : "' + regexName + '"');
      _log.debug(regex);
      regex.lastIndex = 0;
      while ((r = regex.exec(content)) !== null) {

        // Result expected [STRING, KEY, SOME_REGEX_STUF]
        // Except for plural hack [STRING, KEY, ARRAY_IN_STRING]
        if (r.length >= 2) {
          var translationKey, evalString;
          var translationDefaultValue = "";

          switch (regexName) {
            case 'HtmlDirectivePluralFirst':
              var tmp = r[1];
              r[1] = r[2];
              r[2] = tmp;
              /* falls through */
            case 'HtmlDirectivePluralLast':
              evalString = eval(r[2]);
              if (_.isArray(evalString) && evalString.length >= 2) {
                translationDefaultValue = "{NB, plural, one{" + evalString[0] + "} other{" + evalString[1] + "}" + (evalString[2] ? ' ' + evalString[2] : '');
              }
              translationKey = r[1].trim();
              break;
            default:
              translationKey = r[1].trim();
          }

          // Avoid empty translation
          if (translationKey === "") {
            return;
          }

          switch (regexName) {
            case "commentSimpleQuote":
            case "HtmlFilterSimpleQuote":
            case "JavascriptServiceSimpleQuote":
            case "JavascriptServiceInstantSimpleQuote":
            case "JavascriptFilterSimpleQuote":
            case "HtmlNgBindHtml":
              translationKey = translationKey.replace(/\\\'/g, "'");
              break;
            case "commentDoubleQuote":
            case "HtmlFilterDoubleQuote":
            case "JavascriptServiceDoubleQuote":
            case "JavascriptServiceInstantDoubleQuote":
            case "JavascriptFilterDoubleQuote":
              translationKey = translationKey.replace(/\\\"/g, '"');
              break;
            case "JavascriptServiceArraySimpleQuote":
            case "JavascriptServiceArrayDoubleQuote":
              var key;

              if(regexName === "JavascriptServiceArraySimpleQuote") {
                key = translationKey.replace(/'/g, '');
              } else {
                key = translationKey.replace(/"/g, '');
              }
              key = key.replace(/[\][]/g, '');
              key = key.split(',');

              key.forEach(function(item){
                item = item.replace(/\\\"/g, '"').trim();
                if (results[item]) {
                  results[item].sourceFiles.push({
                    file: file,
                    line: lineNumber
                  });
                } else {
                  results[item] = {
                    defaultValue: translationDefaultValue,
                    sourceFiles: [{
                      file: file,
                      line: lineNumber
                    }]
                  };
                }
              });
              break;
          }

          if( regexName !== "JavascriptServiceArraySimpleQuote" &&
              regexName !== "JavascriptServiceArrayDoubleQuote") {
            if (results[translationKey]) {
              results[translationKey].sourceFiles.push({
                file: file,
                line: lineNumber
              });
            } else {
              results[ translationKey ] = {
                defaultValue: translationDefaultValue,
                sourceFiles: [{
                  file: file,
                  line: lineNumber
                }]
              };
            }
          }
        }
      }
    }
1017660
function toOriginalText(item) {
    if (_.has(item, "tokenName")) {
        return item.tokenName
    } else if (item instanceof Rule) {
        return item.name
    } else if (_.isString(item)) {
        return item
    } else if (_.has(item, "toRule")) {
        return item.definition.orgText
    } else {
        throw Error(`Unexpected Argument type ${item}`)
    }
}
337857
def get_translations(self, domain=None, locale=None):
        
        if locale is None:

            if self.locale is None:
                return support.NullTranslations()

            locale = self.locale

        if domain is None:
            domain = self.cfg.domain

        if (domain, locale.language) not in self.translations:
            translations = None
            for locales_dir in reversed(self.cfg.locales_dirs):
                trans = support.Translations.load(
                    locales_dir, locales=locale, domain=domain)
                if translations:
                    translations._catalog.update(trans._catalog)
                else:
                    translations = trans

            self.translations[(domain, locale.language)] = translations

        return self.translations[(domain, locale.language)]
1297388
def translate(self):
        """"""

        value = super().translate()
        if value is None or (isinstance(value, str) and value.strip() == ''):
            return None

        return int(value)
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)))