Documentation
¶
Index ¶
- Constants
- Variables
- func AddCommand(cfg *config.Config, args *AddCommandArguments) error
- func AddCommandInteractive(cfg *config.Config, api jsonapi.Connection) error
- func AddRemoteCommand(cfg *config.Config, api *jsonapi.Connection, projectUrl, fileFilter string, ...) error
- func DeleteCommand(cfg *config.Config, api jsonapi.Connection, arguments *DeleteCommandArguments) error
- func GetClient(cacert string) (http.Client, error)
- func GetHostAndToken(cfg *config.Config, hostname, token string) (string, string, error)
- func InitCommand() error
- func MergeCommand(cfg *config.Config, api jsonapi.Connection, args MergeCommandArguments) error
- func MigrateLegacyConfigFile(cfg *config.Config, api jsonapi.Connection) (string, error)
- func PullCommand(cfg *config.Config, api *jsonapi.Connection, args *PullCommandArguments) error
- func PushCommand(cfg *config.Config, api jsonapi.Connection, args PushCommandArguments) error
- func StatusCommand(cfg *config.Config, api jsonapi.Connection, arguments *StatusCommandArguments) error
- func UpdateCommand(arguments UpdateCommandArguments) error
- type AddCommandArguments
- type DeleteCommandArguments
- type FilePullTask
- type LanguagePushTask
- type MergeCommandArguments
- type MergeResourcePollTask
- type PullCommandArguments
- type PushCommandArguments
- type ResourcePullTask
- type ResourcePushTask
- type SourceFilePushTask
- type StatusCommandArguments
- type TargetLanguageMessage
- type TranslationFileTask
- type UpdateCommandArguments
Constants ¶
const PathSeparator = string(os.PathSeparator)
Variables ¶
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://developers.transifex.com/docs/cli#installation.`,
"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?",
},
}
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 DeleteCommand ¶ added in v0.0.2
func DeleteCommand( cfg *config.Config, api jsonapi.Connection, arguments *DeleteCommandArguments, ) error
func GetHostAndToken ¶
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:
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.
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.
- 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 ¶
MigrateLegacyConfigFile Edits legacy config files so they contain all the necessary information to use the 3rd version of the API. Steps taken:
- Check for token setting. If not found check for API token in the old configuration. If not found generate one.
- Check for rest_hostname setting. If not found add it.
- 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 DeleteCommandArguments ¶ added in v0.0.2
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 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 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())