txlib

package
v1.6.11 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const PathSeparator = string(os.PathSeparator)

Variables

View Source
var PromptMap = map[string]map[string]string{
	"sourceFile": {
		"text": `
The Transifex Client syncs files between your local directory and Transifex.
The mapping configuration between the two is stored in a file called .tx/config
in your current directory. For more information, visit
https://docs.transifex.com/client/config/.`,
		"label": "What is the path of the source file?",
	},
	"fileFilter": {
		"text": `
Next, we’ll need a path expression pointing to the location of the
translation files (whether they exist yet or not) associated with
the source file ‘%s’.
You should include <lang> as a wildcard for the language code.
Example: 'path/<lang>/%s'`,
		"label": "What is your path expression?",
	},
}
View Source
var Version string

Functions

func AddCommand

func AddCommand(
	cfg *config.Config,
	args *AddCommandArguments,
) error

func AddCommandInteractive

func AddCommandInteractive(cfg *config.Config, api jsonapi.Connection) error

func AddRemoteCommand added in v1.3.0

func AddRemoteCommand(
	cfg *config.Config,
	api *jsonapi.Connection,
	projectUrl,
	fileFilter string,
	minimumPerc int,
) error

func DeleteCommand added in v0.0.2

func DeleteCommand(
	cfg *config.Config,
	api jsonapi.Connection,
	arguments *DeleteCommandArguments,
) error

func GetClient

func GetClient(cacert string) (http.Client, error)

func GetHostAndToken

func GetHostAndToken(
	cfg *config.Config, hostname, token string,
) (string, string, error)

GetHostAndToken Function for getting the *final* API server hostname and token from a combination of environment variables, flags, config files and/or user input.

  • 'cfg' is a 'config.Config' object that has already been loaded either based on the default configuration paths or ones that have been supplied by the user.
  • 'hostname' is an override for the hostname to used that the user has maybe provided either as a flag or an environment variable.
  • 'token' is an override for the API token to be used that the user has maybe provided either as a flag or an environment variable.

The logic for retrieving the final hostname and token is:

  1. If the hostname flag/env variable is provided, use it as a section *key* in the root configuration file. For example, if the user provides 'aaa' and the root configuration file looks like this:

    [aaa] rest_hostname = bbb

    Then, the returned hostname will be 'bbb'.

    If a matching host isn't found, then the returned hostname will be the provided value.

  1. If the user didn't provide a hostname, try to find the "active host" based on both the local and root configuration. For example, if the local configuration looks like this:

    [main] host = ccc

    And the root configuration looks like this:

    [aaa] rest_hostname = bbb

    [ccc] rest_hostname = ddd

    [eee] rest_hostname = fff

    Then the "active host" will be the second one and the returned hostname will be 'ddd'.

    If an active host cannot be found, then 'https://rest.api.transifex.com' will be returned.

3. If a token was provided by the user, simply return it.

  1. If a token wasn't provided, retrieve the token from either the "matching host" (see step 1) or the "active host" (see step 2). If a "matching" or "active" host wasn't found during the resolution of the hostname, the program will ask the user to provide a token. After the token is provided, it will be saved in the root configuration using the appropriate section key and hostname that were already retrieved.

func InitCommand

func InitCommand() error

func MergeCommand added in v1.5.0

func MergeCommand(
	cfg *config.Config,
	api jsonapi.Connection,
	args MergeCommandArguments,
) error

func MigrateLegacyConfigFile

func MigrateLegacyConfigFile(
	cfg *config.Config, api jsonapi.Connection,
) (string, error)

MigrateLegacyConfigFile Edits legacy config files so they contain all the necessary information to use the 3rd version of the API. Steps taken:

  1. Check for token setting. If not found check for API token in the old configuration. If not found generate one.
  2. Check for rest_hostname setting. If not found add it.
  3. Check the section keys are using the legacy format (`<project_slug>.<resource_slug>`) If yes find the organization for each section key and reformat the section key to conform to the new format (o:<organization_slug>:p:<project_slug>:r:<resource_slug>)

func PullCommand

func PullCommand(
	cfg *config.Config,
	api *jsonapi.Connection,
	args *PullCommandArguments,
) error

func PushCommand

func PushCommand(
	cfg *config.Config,
	api jsonapi.Connection,
	args PushCommandArguments,
) error

func StatusCommand added in v0.0.2

func StatusCommand(
	cfg *config.Config,
	api jsonapi.Connection,
	arguments *StatusCommandArguments,
) error

func UpdateCommand added in v0.1.0

func UpdateCommand(arguments UpdateCommandArguments) error

Types

type AddCommandArguments

type AddCommandArguments struct {
	OrganizationSlug string
	ProjectSlug      string
	ResourceSlug     string
	FileFilter       string
	RType            string
	SourceFile       string
	ResourceName     string
}

type DeleteCommandArguments added in v0.0.2

type DeleteCommandArguments struct {
	ResourceIds []string
	Force       bool
	Skip        bool
	Branch      string
}

type FilePullTask added in v1.2.0

type FilePullTask struct {
	// contains filtered or unexported fields
}

func (*FilePullTask) Run added in v1.2.0

func (task *FilePullTask) Run(send func(string), abort func())

type LanguagePushTask added in v1.2.0

type LanguagePushTask struct {
	// contains filtered or unexported fields
}

func (*LanguagePushTask) Run added in v1.2.0

func (task *LanguagePushTask) Run(send func(string), abort func())

type MergeCommandArguments added in v1.5.0

type MergeCommandArguments struct {
	ResourceId         string
	Branch             string
	ConflictResolution string
	Force              bool
	Skip               bool
	Silent             bool
}

type MergeResourcePollTask added in v1.5.0

type MergeResourcePollTask struct {
	// contains filtered or unexported fields
}

func (*MergeResourcePollTask) Run added in v1.5.0

func (task *MergeResourcePollTask) Run(send func(string), abort func())

type PullCommandArguments

type PullCommandArguments struct {
	FileType          string
	Mode              string
	ContentEncoding   string
	Force             bool
	Skip              bool
	Languages         []string
	Source            bool
	Translations      bool
	All               bool
	DisableOverwrite  bool
	KeepNewFiles      bool
	ResourceIds       []string
	UseGitTimestamps  bool
	Branch            string
	MinimumPercentage int
	Workers           int
	Silent            bool
	Pseudo            bool
}

type PushCommandArguments

type PushCommandArguments struct {
	Source               bool
	Translation          bool
	Force                bool
	Skip                 bool
	Xliff                bool
	Languages            []string
	ResourceIds          []string
	UseGitTimestamps     bool
	Branch               string
	Base                 string
	All                  bool
	Workers              int
	Silent               bool
	ReplaceEditedStrings bool
	KeepTranslations     bool
}

type ResourcePullTask added in v1.2.0

type ResourcePullTask struct {
	// contains filtered or unexported fields
}

func (*ResourcePullTask) Run added in v1.2.0

func (task *ResourcePullTask) Run(send func(string), abort func())

type ResourcePushTask added in v1.2.0

type ResourcePushTask struct {
	// contains filtered or unexported fields
}

func (*ResourcePushTask) Run added in v1.2.0

func (task *ResourcePushTask) Run(send func(string), abort func())

type SourceFilePushTask added in v1.2.0

type SourceFilePushTask struct {
	// contains filtered or unexported fields
}

func (*SourceFilePushTask) Run added in v1.2.0

func (task *SourceFilePushTask) Run(send func(string), abort func())

type StatusCommandArguments added in v0.0.2

type StatusCommandArguments struct {
	ResourceIds []string
}

type TargetLanguageMessage added in v1.2.0

type TargetLanguageMessage struct {
	// contains filtered or unexported fields
}

type TranslationFileTask added in v1.2.0

type TranslationFileTask struct {
	// contains filtered or unexported fields
}

func (*TranslationFileTask) Run added in v1.2.0

func (task *TranslationFileTask) Run(send func(string), abort func())

type UpdateCommandArguments added in v0.1.0

type UpdateCommandArguments struct {
	Version       string
	NoInteractive bool
	Check         bool
	Debug         bool
}

Directories

Path Synopsis
Package config Slightly object-oriented tx configuration package.
Package config Slightly object-oriented tx configuration package.

Jump to

Keyboard shortcuts

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