internal

package
v0.0.0-...-455340e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StepAskForToken   = "ask for token"
	StepSelectProject = "select project"
	StepSelectFormat  = "select format"
	StepConfigSources = "config sources"
	StepConfigTargets = "config targets"
	StepWriteConfig   = "write configuration file"
	StepFinished      = "finished"
)

The steps for a successful project initialization.

Variables

View Source
var Config *phrase.Config
View Source
var Debug bool

Functions

func Projects

func Projects(client *phrase.APIClient) ([]phrase.Project, *phrase.APIResponse, error)

func RemoteLocales

func RemoteLocales(client *phrase.APIClient, key LocaleCacheKey) ([]*phrase.Locale, *phrase.APIResponse, error)

func StringToInterface

func StringToInterface() mapstructure.DecodeHookFunc

StringToInterface returns a DecodeHookFunc that converts strings to optional.Interface.

func StringToOptionalBool

func StringToOptionalBool() mapstructure.DecodeHookFunc

StringToOptionalBool returns a DecodeHookFunc that converts strings to optional.Bool.

func StringToOptionalString

func StringToOptionalString() mapstructure.DecodeHookFunc

StringToOptionalString returns a DecodeHookFunc that converts strings to optional.String.

func UploadCleanup

func UploadCleanup(client *phrase.APIClient, confirm bool, ids []string, branch string, projectId string) error

func ViperStructTag

func ViperStructTag() viper.DecoderConfigOption

Types

type ConfigYAML

type ConfigYAML struct {
	Host        string                            `yaml:"host,omitempty"`
	AccessToken string                            `yaml:"access_token,omitempty"`
	ProjectID   string                            `yaml:"project_id"`
	FileFormat  string                            `yaml:"file_format,omitempty"`
	PerPage     int                               `yaml:"per_page,omitempty"`
	Defaults    map[string]map[string]interface{} `yaml:"defaults,omitempty"`
	Push        PushYAML                          `yaml:"push,omitempty"`
	Pull        PullYAML                          `yaml:"pull,omitempty"`
}

type InitCommand

type InitCommand struct {
	phrase.Config

	YAML       ConfigYAML
	FileFormat *phrase.Format
	// contains filtered or unexported fields
}

func (*InitCommand) Run

func (cmd *InitCommand) Run() error

type LocaleCache

type LocaleCache map[LocaleCacheKey][]*phrase.Locale

func LocalesForProjects

func LocalesForProjects(client *phrase.APIClient, projectLocales ProjectLocales, branch string) (LocaleCache, error)

type LocaleCacheKey

type LocaleCacheKey struct {
	ProjectID string
	Branch    string
}

type LocaleFile

type LocaleFile struct {
	Path, Name, ID, Code, Tag, FileFormat string
	ExistsRemote                          bool
}

func (*LocaleFile) Message

func (localeFile *LocaleFile) Message() string

Locale to Path mapping

func (*LocaleFile) RelPath

func (localeFile *LocaleFile) RelPath() string

type LocaleFiles

type LocaleFiles []*LocaleFile

type ProjectLocales

type ProjectLocales interface {
	ProjectIds() []string
}

type PullCommand

type PullCommand struct {
	phrase.Config
	Branch             string
	UseLocalBranchName bool
}

func (*PullCommand) Run

func (cmd *PullCommand) Run(config *phrase.Config) error

type PullParams

type PullParams struct {
	phrase.LocaleDownloadOpts `json:",squash" mapstructure:",squash"`
	LocaleID                  string `json:"locale_id"`
}

type PullYAML

type PullYAML struct {
	Targets []TargetsYAML `yaml:"targets,omitempty"`
}

type PushCommand

type PushCommand struct {
	phrase.Config
	Wait               bool
	Cleanup            bool
	Branch             string
	UseLocalBranchName bool
	Tag                string
}

func (*PushCommand) Run

func (cmd *PushCommand) Run() error

type PushYAML

type PushYAML struct {
	Sources []SourcesYAML `yaml:"sources,omitempty"`
}

type Source

type Source struct {
	File        string        `json:"file"`
	ProjectID   string        `json:"project_id"`
	Branch      string        `json:"branch"`
	AccessToken string        `json:"access_token"`
	FileFormat  string        `json:"file_format"`
	Params      *UploadParams `json:"params,omitempty"`

	RemoteLocales []*phrase.Locale
	Format        *phrase.Format
}

func (*Source) CheckPreconditions

func (source *Source) CheckPreconditions() error

func (*Source) GetFileFormat

func (source *Source) GetFileFormat() string

func (*Source) GetLocaleID

func (source *Source) GetLocaleID() string

func (*Source) LocaleFiles

func (source *Source) LocaleFiles() (LocaleFiles, error)

Return all locale files from disk that match the source pattern.

func (*Source) Push

func (source *Source) Push(client *phrase.APIClient, waitForResults bool, cleanup bool, branch string, tag string) error

type Sources

type Sources []*Source

func SourcesFromConfig

func SourcesFromConfig(config phrase.Config) (Sources, error)

func (Sources) ProjectIds

func (sources Sources) ProjectIds() []string

func (Sources) Validate

func (sources Sources) Validate() error

type SourcesYAML

type SourcesYAML struct {
	File   string                 `yaml:"file,omitempty"`
	Params map[string]interface{} `yaml:"params,omitempty"`
}

type Target

type Target struct {
	File          string      `json:"file"`
	ProjectID     string      `json:"project_id"`
	AccessToken   string      `json:"access_token"`
	FileFormat    string      `json:"file_format"`
	Params        *PullParams `json:"params" mapstructure:"omittable-nested,omitempty"`
	RemoteLocales []*phrase.Locale
}

func (*Target) CheckPreconditions

func (target *Target) CheckPreconditions() error

func (*Target) DownloadAndWriteToFile

func (target *Target) DownloadAndWriteToFile(client *phrase.APIClient, localeFile *LocaleFile, branch string) error

func (*Target) GetFormat

func (t *Target) GetFormat() string

func (*Target) GetLocaleID

func (t *Target) GetLocaleID() string

func (*Target) GetTags

func (t *Target) GetTags() []string

func (*Target) LocaleFiles

func (target *Target) LocaleFiles() (LocaleFiles, error)

func (*Target) Pull

func (target *Target) Pull(client *phrase.APIClient, branch string) error

func (*Target) ReplacePlaceholders

func (target *Target) ReplacePlaceholders(localeFile *LocaleFile) (string, error)

type Targets

type Targets []*Target

func TargetsFromConfig

func TargetsFromConfig(config phrase.Config) (Targets, error)

func (Targets) ProjectIds

func (targets Targets) ProjectIds() []string

type TargetsYAML

type TargetsYAML SourcesYAML

type UploadCleanupCommand

type UploadCleanupCommand struct {
	phrase.Config
	IDs       []string
	ProjectID string
	Confirm   bool
	Branch    string
}

func (*UploadCleanupCommand) Run

func (cmd *UploadCleanupCommand) Run() error

type UploadParams

type UploadParams struct {
	phrase.UploadCreateOpts `mapstructure:",squash"`
	LocaleId                optional.String `json:"locale_id,omitempty"`
	FileFormat              optional.String `json:"file_format,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL