コード例 #1
0
ファイル: pull.go プロジェクト: marxbeck/phraseapp-client
func (target *Target) DownloadAndWriteToFile(localeFile *LocaleFile) error {
	downloadParams := target.setDownloadParams()

	params := target.Params
	localeId := ""
	if params != nil && params.LocaleId != "" {
		localeId = params.LocaleId
	} else {
		localeId = localeFile.Id
	}

	if Debug {
		fmt.Println("Target file pattern:", target.File)
		fmt.Println("Actual file path", localeFile.Path)
		fmt.Println("LocaleId", localeId)
		fmt.Println("ProjectId", target.ProjectId)
		fmt.Println("FileFormat", downloadParams.FileFormat)
		fmt.Println("ConvertEmoji", downloadParams.ConvertEmoji)
		fmt.Println("IncludeEmptyTranslations", downloadParams.IncludeEmptyTranslations)
		fmt.Println("KeepNotranslateTags", downloadParams.KeepNotranslateTags)
		fmt.Println("Tag", downloadParams.Tag)
		fmt.Println("FormatOptions", downloadParams.FormatOptions)
	}

	res, err := phraseapp.LocaleDownload(target.ProjectId, localeId, downloadParams)
	if err != nil {
		return err
	}

	err = ioutil.WriteFile(localeFile.Path, res, 0700)
	if err != nil {
		return err
	}
	return nil
}
コード例 #2
0
ファイル: pull.go プロジェクト: robmorgan/phraseapp-client
func (target *Target) DownloadAndWriteToFile(localeFile *LocaleFile) error {
	downloadParams := target.setDownloadParams()

	params := target.Params
	localeId := ""
	if params != nil && params.LocaleId != "" {
		localeId = params.LocaleId
	} else {
		localeId = localeFile.Id
	}

	res, err := phraseapp.LocaleDownload(target.ProjectId, localeId, downloadParams)
	if err != nil {
		return err
	}

	err = ioutil.WriteFile(localeFile.Path, res, 0700)
	if err != nil {
		return err
	}
	return nil
}