Translates the properties as much as possible, and truncates at the first non-translatable property
768869
public static <X, Y> List<LocalProperty<Y>> translate(List<? extends LocalProperty<X>> properties, Function<X, Optional<Y>> translator)
    {
        properties = normalizeAndPrune(properties);

        ImmutableList.Builder<LocalProperty<Y>> builder = ImmutableList.builder();
        for (LocalProperty<X> property : properties) {
            Optional<LocalProperty<Y>> translated = property.translate(translator);
            if (translated.isPresent()) {
                builder.add(translated.get());
            }
            else if (!(property instanceof ConstantProperty)) {
                break; // Only break if we fail to translate non-constants
            }
        }

        return builder.build();
    }
960675
def trunc(self, model, prompt, **fields):
        
        for field_name, value in fields.items():
            field = model._meta.get_field(field_name)
            max_length = getattr(field, "max_length", None)
            if not max_length:
                continue
            elif not prompt:
                fields[field_name] = value[:max_length]
                continue
            while len(value) > max_length:
                encoded_value = value.encode("utf-8")
                new_value = input("The value for the field %s.%s exceeds "
                    "its maximum length of %s chars: %s\n\nEnter a new value "
                    "for it, or press return to have it truncated: " %
                    (model.__name__, field_name, max_length, encoded_value))
                value = new_value if new_value else value[:max_length]
            fields[field_name] = value
        return fields
393196
def translated_value(self):
        
        if self.typeof in self:
            return NATValue(self.get(self.typeof, {}).get(
                'translated_value'))
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }
1053002
def truncate(data, l=20):
    ""
    info = (data[:l] + '..') if len(data) > l else data
    return info
1060044
private static void truncateInternalProperties(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
    try (PreparedStatement preparedStatement = connection.prepareStatement("delete from internal_properties where kee not in (?,?)")) {
      preparedStatement.setString(1, InternalProperties.DEFAULT_ORGANIZATION);
      preparedStatement.setString(2, InternalProperties.SERVER_ID_CHECKSUM);
      preparedStatement.execute();
      // commit is useless on some databases
      connection.commit();
    }
  }
200309
private static String translateEncoding(final String encodingName) throws UnsupportedEncodingException
	{
		try
		{
			String _encoding = encodingName.trim().toLowerCase();
			String _encodingCode = theEncodingResource.getString(_encoding);

			return _encodingCode;
		} // try
		catch (MissingResourceException _exception)
		{
			throw new UnsupportedEncodingException(theMessageUnsupportedEncoding + encodingName);
		} // catch(MissingResourceException _exception)
		catch (Exception _exception)
		{
			throw new UnsupportedEncodingException(theMessageErrorTranslatingEncoding + encodingName);
		} // catch (Exception _exception)
	}
1317975
function filterTranslate (translateList, words) {
  if (translateList && translateList.length === 1 && translateList[0].trans === words) {
    return []
  }

  return translateList
}
703678
function normalizeProperties(input) {
  if (!input) return;

  if (Array.isArray(input)) {
    return flatten(input).reduce(function (acc, o) {
      return Object.assign(acc, o);
    }, {});
  }

  return clone(input);
}
619304
def shorten(original_chars, chars, length_without_trailing)
      truncated = []
      char_width = display_width(chars[0])
      while length_without_trailing - char_width > 0
        orig_char = original_chars.shift
        char = chars.shift
        break unless char
        while orig_char != char # consume ansi
          ansi = true
          truncated << orig_char
          orig_char = original_chars.shift
        end
        truncated << char
        char_width = display_width(char)
        length_without_trailing -= char_width
      end
      truncated << ["\e[0m"] if ansi
      truncated
    end
100959
function normalizeProperties(properties, name) {
        // Allow for shorthand type declaration:

        // Check to see if the user passed in a raw type of a properties hash.
        if (properties) {
            // Raw type passed.
            // index: Type is translated to index: {type: Type}
            // Properties hash created.
            if (properties.type === undefined) {
                properties = {
                    type: properties
                };

                // Properties hash passed.
                // Copy properties hash before modifying.
                // Users can pass in their own custom types to the schema and we don't want to write to that object.
                // Especially since properties.name contains the index of our field and copying that will break functionality.
            } else {
                properties = _.cloneDeep(properties);
            }
        }

        // Type may be an object with properties.
        // If "type.type" exists, we'll assume it's meant to be properties.
        // This means that shorthand objects can't use the "type" index.
        // If "type" is necessary, they must be wrapped in a SchemaObject.
        if (_.isObject(properties.type) && properties.type.type !== undefined) {
            _.each(properties.type, (value, key) => {
                if (properties[key] === undefined) {
                    properties[key] = value;
                }
            });
            properties.type = properties.type.type;
        }

        // Null or undefined should be flexible and allow any value.
        if (properties.type === null || properties.type === undefined) {
            properties.type = 'any';

            // Convert object representation of type to lowercase string.
            // String is converted to 'string', Number to 'number', etc.
            // Do not convert the initialized SchemaObjectInstance to a string!
            // Check for a shorthand declaration of schema by key length.
        } else if (_.isString(properties.type.name) && properties.type.name !== 'SchemaObjectInstance' &&
            Object.keys(properties.type).length === 0) {
            properties.type = properties.type.name;
        }
        if (_.isString(properties.type)) {
            properties.type = properties.type.toLowerCase();
        }

        // index: [Type] or index: [] is translated to index: {type: Array, arrayType: Type}
        if (_.isArray(properties.type)) {
            if (_.size(properties.type)) {
                // Properties will be normalized when array is initialized.
                properties.arrayType = properties.type[0];
            }
            properties.type = 'array';
        }

        // index: {} or index: SchemaObject is translated to index: {type: Object, objectType: Type}
        if (!_.isString(properties.type)) {
            if (_.isFunction(properties.type)) {
                properties.objectType = properties.type;
                properties.type = 'object';
            } else if (_.isObject(properties.type)) {
                // When an empty object is passed, no schema is enforced.
                if (_.size(properties.type)) {
                    // Options should be inherited by sub-SchemaObjects, except toObject.
                    const options = _.clone(this[_privateKey]._options);
                    delete options.toObject;

                    // When we're creating a nested schema automatically, it should always inherit the root "this".
                    options.inheritRootThis = true;

                    // Initialize the SchemaObject sub-schema automatically.
                    properties.objectType = new SchemaObject(properties.type, options);
                }

                // Regardless of if we created a sub-schema or not, the field is indexed as an object.
                properties.type = 'object';
            }
        }

        // Set name if passed on properties.
        // It's used to show what field an error what generated on.
        if (name) {
            properties.name = name;
        }

        return properties;
    }
1309180
function Translator(api, options) {
  var origLength = JSON.stringify(api, null, 2).length;
  var debugInfo = {flattened: {}, pruned: {}};
  var shapeName = 'S0';
  var shapeNameMap = {};
  var visitedShapes = {};

  function logResults() {
    console.log('** Generated', api.metadata.endpointPrefix + '-' +
      api.metadata.apiVersion +'.min.json' +
      (process.env.DEBUG ? ':' : ''));

    if (process.env.DEBUG) {
      var pruned = Object.keys(debugInfo.pruned);
      var flattened = Object.keys(debugInfo.flattened);
      var newLength = JSON.stringify(api, null, 2).length;
      console.log('- Pruned Shapes:', pruned.length);
      console.log('- Flattened Shapes:', flattened.length);
      console.log('- Remaining Shapes:', Object.keys(api.shapes).length);
      console.log('- Original Size:', origLength / 1024.0, 'kb');
      console.log('- Minified Size:', newLength / 1024.0, 'kb');
      console.log('- Size Saving:', (origLength - newLength) / 1024.0, 'kb');
      console.log('');
    }
  }

  function deleteTraits(obj) {
    if (!options.documentation) {
      delete obj.documentation;
      delete obj.documentationUrl;
      delete obj.errors;
      delete obj.min;
      delete obj.max;
      delete obj.pattern;
      delete obj['enum'];
      delete obj.box;
    }
  }

  function trackShapeDeclaration(ref) {
    if (ref.shape && !shapeNameMap[ref.shape]) {
      // found a shape declaration we have not yet visited.
      // assign a new generated name in the shapeNameMap & visit it
      var oldShapeName = ref.shape;
      ref.shape = shapeName = nextString(shapeName);

      visitedShapes[shapeName] = api.shapes[oldShapeName];
      shapeNameMap[oldShapeName] = {name: shapeName, refs: [ref]};

      traverseShapeRef(api.shapes[oldShapeName]);
    } else if (ref.shape && shapeNameMap[ref.shape]) {
      // we visited this shape before. keep track of this ref and rename
      // the referenced declaration to the generated name
      var map = shapeNameMap[ref.shape];
      map.refs.push(ref);
      ref.shape = map.name;        
    }
  }

  function pruneShapes() {
    // prune shapes visited only once or only have type specifiers
    each(shapeNameMap, function(name, map) {
      if (Object.keys(visitedShapes[map.name]).join() === 'type' &&
          ['structure','map','list'].indexOf(visitedShapes[map.name].type) < 0) {
        // flatten out the shape (only a scalar type property is on the shape)
        for (var i = 0; i < map.refs.length; i++) {
          var ref = map.refs[i];
          debugInfo.flattened[name] = true;
          delete ref.shape;
          ref.type = visitedShapes[map.name].type;

          // string type is default, don't need to specify this
          if (ref.type === 'string') delete ref.type;
        }

        // we flattened all refs, we can prune the shape too
        delete visitedShapes[map.name];
        debugInfo.pruned[name] = true;
      } else if (map.refs.length === 1) { // only visited once
        // merge shape data onto ref
        var shape = visitedShapes[map.name];

        for (var i = 0; i < map.refs.length; i++) {
          delete map.refs[i].shape;
          for (var prop in shape) {
            if (shape.hasOwnProperty(prop)) {
              //Translator prefers timestampFormat trait in members rather than in shape
              if (map.refs[i].hasOwnProperty(prop) && ['timestampFormat'].indexOf(prop) >= 0) {
                continue;
              }
              map.refs[i][prop] = shape[prop];
            }
            
          }
        }

        // delete the visited shape
        delete visitedShapes[map.name];
        debugInfo.pruned[name] = true;
      }
    });
  }

  function traverseShapeRef(ref) {
    if (!ref) return;

    deleteTraits(ref);

    traverseShapeRef(ref.key); // for maps
    traverseShapeRef(ref.value); // for maps
    traverseShapeRef(ref.member); // for lists

    // for structures
    each(ref.members || {}, function(key, value) { traverseShapeRef(value); });

    // resolve shape declarations
    trackShapeDeclaration(ref);
  }

  function traverseOperation(op) {
    deleteTraits(op);

    delete op.name;
    if (op.http) {
      if (op.http.method === 'POST') delete op.http.method;
      if (op.http.requestUri === '/') delete op.http.requestUri;
      if (Object.keys(op.http).length === 0) delete op.http;
    }

    traverseShapeRef(op.input);
    traverseShapeRef(op.output);    
  }

  function traverseApi() {
    deleteTraits(api);
    each(api.operations, function(name, op) { traverseOperation(op); });
    api.shapes = visitedShapes;
  }

  traverseApi();
  pruneShapes();
  logResults();
  return api;
}
1310132
def translate_paths (properties, path):
    
    assert is_iterable_typed(properties, Property)
    result = []

    for p in properties:

        if p.feature.path:
            values = __re_two_ampersands.split(p.value)

            new_value = "&&".join(os.path.normpath(os.path.join(path, v)) for v in values)

            if new_value != p.value:
                result.append(Property(p.feature, new_value, p.condition))
            else:
                result.append(p)

        else:
            result.append (p)

    return result
489962
function truncate(str, maxLength) {
	maxLength = maxLength || 300;

	if (str.length > maxLength) {
		var index = str.indexOf('>');
		str = str.substring(0, index + 1);
	}

	return str;
}
1101356
function (trans, val) {
		var key,
			tmpArr = {},
			isArr = $.isArray(trans);
		for (key in trans) {
			if (isArr || trans.hasOwnProperty(key)) {
				tmpArr[trans[key]] = val || key;
			}
		}
		return tmpArr;
	}
1297388
def translate(self):
        """"""

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

        return int(value)
247628
function truncate(el) {
    if (!el) {
        return;
    }

    const text = el.textContent;

    if (this.isTextOverflowing(el)) {
        const checkFunc = i => {
            el.textContent = text.substring(0, i);
            return this.isTextOverflowing(el) ? -1 : 0;
        };
        const len = binarySearch(text.length - 1, checkFunc);
        const truncatedText = text.substring(0, len).slice(0, -2);
        el.innerHTML = `<span aria-hidden="true">${truncatedText}…</span><span class="clipped">${text}</span>`;
    }
}