// TranslateDateRef returns the time the value represents with undetermined
// items filled in from the reference time. The biases list is for the call to
// TranslateYMD that is made, see there for more detail.
498116
func TranslateDateRef(value string, biases []string, reference time.Time) time.Time {
	year, month, day := TranslateYMD(value, biases)
	if year == 0 {
		year = reference.Year()
	}
	if month == 0 {
		month = int(reference.Month())
	}
	if day == 0 {
		day = reference.Day()
	}
	return time.Date(year, time.Month(month), day, reference.Hour(), reference.Minute(), reference.Second(), reference.Nanosecond(), reference.Location())
}
842407
func Translate2D(Tx, Ty float32) Mat3 {
	return Mat3{1, 0, 0, 0, 1, 0, float32(Tx), float32(Ty), 1}
}
1133231
func (f *Field) Translate(text string, args ...interface{}) string {
	if f.controller != nil {
		text = f.controller.Message(text, args...)
	}
	return text
}
409503
func (t *Translator) formatDateTimeComponentYear(datetime time.Time, length int) (string, error) {
	year := datetime.Year()
	switch length {
	case datetimeFormatLength1Plus:
		return t.formatDateTimeComponentYearLengthWide(year), nil
	case datetimeFormatLength2Plus:
		return t.formatDateTimeComponentYearLength2Plus(year), nil
	case datetimeFormatLengthWide:
		return t.formatDateTimeComponentYearLengthWide(year), nil
	}

	return "", translatorError{message: fmt.Sprintf("unsupported year length: %d", length)}
}
467726
func NewTypeDef(init ...*TypeDef) *TypeDef {
	var o *TypeDef
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(TypeDef)
	}
	return o
}
1101425
func (ui *UI) TranslateText(template string, templateValues ...map[string]interface{}) string {
	return ui.translate(template, getFirstSet(templateValues))
}
439443
func SizeDef(size string, defSize uint64) (s uint64) {
	var err error
	if s, err = Size(size); err != nil {
		return defSize
	}

	return s
}
758153
func (s *translateStore) TranslateColumnToString(index string, values uint64) (string, error) {
	return "", pilosa.ErrNotImplemented
}
18351
func (c *CreateEvent) GetRef() string {
	if c == nil || c.Ref == nil {
		return ""
	}
	return *c.Ref
}
153251
func (ve ValidationErrors) Translate(ut ut.Translator) ValidationErrorsTranslations {

	trans := make(ValidationErrorsTranslations)

	var fe *fieldError

	for i := 0; i < len(ve); i++ {
		fe = ve[i].(*fieldError)

		// // in case an Anonymous struct was used, ensure that the key
		// // would be 'Username' instead of ".Username"
		// if len(fe.ns) > 0 && fe.ns[:1] == "." {
		// 	trans[fe.ns[1:]] = fe.Translate(ut)
		// 	continue
		// }

		trans[fe.ns] = fe.Translate(ut)
	}

	return trans
}
426923
func MustCreateRef(ref string) Ref {
	r, err := New(ref)
	if err != nil {
		panic(err)
	}
	return r
}
743130
func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time {
	val := k.MustTimeFormat(format)
	for _, cand := range candidates {
		if val == cand {
			return val
		}
	}
	return defaultVal
}
489965
func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *translateFileReader {
	return &translateFileReader{
		ctx:     ctx,
		store:   store,
		offset:  offset,
		notify:  store.WriteNotify(),
		closing: make(chan struct{}),
	}
}
1113928
func (c *conn) translateArgs(args []interface{}) []interface{} {
	if c.flavor.supportsTimezones {
		return args
	}

	for i, arg := range args {
		if t, ok := arg.(time.Time); ok {
			args[i] = t.UTC()
		}
	}
	return args
}
1364961
func (fe *fieldError) Translate(ut ut.Translator) string {

	m, ok := fe.v.transTagFunc[ut]
	if !ok {
		return fe.Error()
	}

	fn, ok := m[fe.tag]
	if !ok {
		return fe.Error()
	}

	return fn(ut, fe)
}
1014408
func ParseRef(ref string) (*Ref, error) {
	if ref == "" {
		return nil, trace.BadParameter("missing value")
	}
	parts := strings.FieldsFunc(ref, isDelimiter)
	switch len(parts) {
	case 1:
		shortcut, err := ParseShortcut(parts[0])
		if err != nil {
			return nil, trace.Wrap(err)
		}
		return &Ref{Kind: shortcut}, nil
	case 2:
		shortcut, err := ParseShortcut(parts[0])
		if err != nil {
			return nil, trace.Wrap(err)
		}
		return &Ref{Kind: shortcut, Name: parts[1]}, nil
	}
	return nil, trace.BadParameter("failed to parse '%v'", ref)
}
1181505
func DeleteRef(c context.Context, pkg, ref string) error {
	return Txn(c, "DeleteRef", func(c context.Context) error {
		r, err := GetRef(c, pkg, ref)
		switch {
		case grpcutil.Code(err) == codes.NotFound:
			return nil
		case err != nil:
			return err // transient
		}

		err = datastore.Delete(c, &Ref{
			Name:    ref,
			Package: PackageKey(c, pkg),
		})
		if err != nil {
			return transient.Tag.Apply(err)
		}

		return EmitEvent(c, &api.Event{
			Kind:     api.EventKind_INSTANCE_REF_UNSET,
			Package:  pkg,
			Instance: r.InstanceID,
			Ref:      ref,
		})
	})
}