// SaveTranslation save translation
345207
func (i18n *I18n) SaveTranslation(translation *Translation) error {
	for _, backend := range i18n.Backends {
		if backend.SaveTranslation(translation) == nil {
			i18n.AddTranslation(translation)
			return nil
		}
	}

	return errors.New("failed to save translation")
}
345668
func (c *Client) Translate(args []string) (Translate, error) {
	argsStr := strings.Join(args, " ")

	req, err := c.NewRequest("/gifs/translate?s=" + argsStr)
	if err != nil {
		return Translate{}, err
	}

	var translate Translate
	if _, err = c.Do(req, &translate); err != nil {
		return Translate{}, err
	}

	if len(translate.RawData) == 0 {
		return Translate{}, ErrNoRawData
	}

	// Check if the first character in Data is a [
	if translate.RawData[0] == '[' {
		return Translate{}, ErrNoImageFound
	}

	err = json.Unmarshal(translate.RawData, &translate.Data)
	if err != nil {
		return Translate{}, err
	}

	return translate, nil
}
911392
func (po *Po) saveBuffer() {
	// With no context...
	if po.ctxBuffer == "" {
		po.translations[po.trBuffer.ID] = po.trBuffer
	} else {
		// With context...
		if _, ok := po.contexts[po.ctxBuffer]; !ok {
			po.contexts[po.ctxBuffer] = make(map[string]*Translation)
		}
		po.contexts[po.ctxBuffer][po.trBuffer.ID] = po.trBuffer

		// Cleanup current context buffer if needed
		if po.trBuffer.ID != "" {
			po.ctxBuffer = ""
		}
	}

	// Flush Translation buffer
	po.trBuffer = NewTranslation()
}
40881
func (l *Locale) AddTranslator(dom string, tr Translator) {
	l.Lock()

	if l.Domains == nil {
		l.Domains = make(map[string]Translator)
	}
	if l.defaultDomain == "" {
		l.defaultDomain = dom
	}
	l.Domains[dom] = tr

	l.Unlock()
}
923364
func (t *UniversalTranslator) VerifyTranslations() (err error) {

	for _, trans := range t.translators {
		err = trans.VerifyTranslations()
		if err != nil {
			return
		}
	}

	return
}
400706
func Translate(ctx context.Context, format string, args ...interface{}) string {
	return ctx.Translate(format, args...)
}
965451
func (c *Carbon) GetTranslator() (*Translator, error) {
	if c.Translator == nil {
		c.Translator = translator()
	}

	return c.Translator, nil
}
1222088
func (target *AMQPTarget) Save(eventData event.Event) error {
	return target.send(eventData)
}
290707
func translate(t translator.Translator, text, from string, to translator.Language) <-chan string {
	out := make(chan string)
	go func() {
		translation, err := t.Translate(text, from, to.Code)
		if err != nil {
			out <- fmt.Sprintf("Error during translation for %s: %s", to.Name, err.Error())
		} else {
			out <- fmt.Sprintf("%s [%s]: %s", to.Name, to.Code, translation)
		}
		close(out)
	}()
	return out
}
1112139
func (s *BufferStore) SaveTo(m Mutator) error {
	err := s.WalkBuffer(func(k Key, v []byte) error {
		if len(v) == 0 {
			return m.Delete(k)
		}
		return m.Set(k, v)
	})
	return err
}
346501
func (s *translateStore) TranslateColumnToString(index string, value uint64) (string, error) {
	s.mu.RLock()
	if idx := s.cols[index]; idx != nil {
		if ret, ok := idx.reverse[value]; ok {
			s.mu.RUnlock()
			return ret, nil
		}
	}
	s.mu.RUnlock()
	return "", nil
}
314717
func translateLevel(l logging.Level) int {
	switch l {
	case Suppress:
		return -1
	case logging.Error:
		return 0
	case logging.Warning, logging.Info:
		return 1
	default:
		return 2
	}
}
803567
func (e *ErrMissingPluralTranslation) Error() string {

	if _, ok := e.key.(string); !ok {
		return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%#v' and locale '%s'", e.translationType, e.rule, e.key, e.locale)
	}

	return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%s' and locale '%s'", e.translationType, e.rule, e.key, e.locale)
}
964615
func (b *Bundle) ParseTranslationFileBytes(filename string, buf []byte) error {
	basename := filepath.Base(filename)
	langs := language.Parse(basename)
	switch l := len(langs); {
	case l == 0:
		return fmt.Errorf("no language found in %q", basename)
	case l > 1:
		return fmt.Errorf("multiple languages found in filename %q: %v; expected one", basename, langs)
	}
	translations, err := parseTranslations(filename, buf)
	if err != nil {
		return err
	}
	b.AddTranslation(langs[0], translations...)
	return nil
}
1315655
func (m *Msg) Save(db *sqlx.DB) error {
	var pluginName string
	if m.Plugin != nil {
		pluginName = m.Plugin.Config.Name
	}
	q := `INSERT INTO messages
	      (userid, sentence, plugin, route, abotsent, needstraining, flexid,
		flexidtype, trained)
	      VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id`
	row := db.QueryRowx(q, m.User.ID, m.Sentence, pluginName, m.Route,
		m.AbotSent, m.NeedsTraining, m.User.FlexID, m.User.FlexIDType,
		m.Trained)
	if err := row.Scan(&m.ID); err != nil {
		return err
	}
	return nil
}
1225426
func (b *Bundle) MustLoadTranslationFile(filename string) {
	if err := b.LoadTranslationFile(filename); err != nil {
		panic(err)
	}
}
1372343
func TfuncAndLanguage(languageSource string, languageSources ...string) (TranslateFunc, *language.Language, error) {
	tfunc, lang, err := defaultBundle.TfuncAndLanguage(languageSource, languageSources...)
	return TranslateFunc(tfunc), lang, err
}