yaptranslator

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 13 Imported by: 0

README

Yet Another Properties (file) Translator

CircleCI codecov GitHub tag (latest SemVer)

Automated translate properties files by machine translation providers.

# origin en example.2.properties
hello=hello
world=World
a.b.c.d=Hello World

# yapt -f ../resources/example.2.properties -l en -t zh
# translated zh example.2_zh.properties
world = 世界
a.b.c.d = 你好世界
hello = 你好

Install

Install by go get or download binary from release page

Usage

./cli --help
NAME:
   Yet Another Properties (file) Translator - A Command Line Tool

USAGE:
   cli [global options] command [command options] [arguments...]

VERSION:
   SNAPSHOT

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --file value, -f value      file or directory to be processed (default: ".")
   --lang value, -l value      Source Language (default: "en") [$YAPT_SOURCE_LANG]
   --target value, -t value    Target Language (default: "zh") [$YAPT_TARGET_LANG]
   --service value, -s value   Service Provider for YAPT Tool (default: "ALICLOUD") [$YAPT_SERVICE_PROVIDER]
   --username value, -u value  Auth User [$YAPT_AUTH_USER]
   --password value, -p value  Auth User Password [$YAPT_AUTH_PASSWORD]
   --region value, -r value    AUTH Region [$YAPT_REGION]
   --key value, -k value       Auth Access Key [$YAPT_ACCESS_KEY]
   --secret value              Auth Access Secret [$YAPT_ACCESS_SECRET]
   --token value               Auth Token [$YAPT_AUTH_TOKEN]
   --help, -h                  show help
   --version, -v               print the version

Providers

yapt support many different transaltion providers

Alibaba Cloud Translator (Default)

Translator powered by Alibaba Cloud

  • required options:
    • region (Service region, like cn-hangzhou)
    • key (Access Key ID)
    • secret (Access Key Secret)

CHANGELOG

LICENSE

Documentation

Index

Constants

View Source
const (
	// ALICLOUD Translator
	ALICLOUD = TranslatorType("ALICLOUD")
)

Variables

This section is empty.

Functions

func AddSuffixToFileName

func AddSuffixToFileName(path, suffix string) string

AddSuffixToFileName string

func StringifyProperties

func StringifyProperties(p *properties.Properties) string

StringifyProperties with comments

func TranslatePropertiesFile

func TranslatePropertiesFile(props *properties.Properties, translator Translator, lang, target string) (*properties.Properties, error)

TranslatePropertiesFile process

Types

type AliCloudTranslator

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

AliCloudTranslator service

func NewAliCloudTranslator

func NewAliCloudTranslator(region, keyID, keySecret string) (*AliCloudTranslator, error)

NewAliCloudTranslator instance

func (*AliCloudTranslator) GetTranslation

func (t *AliCloudTranslator) GetTranslation(s string, l string, tl string) (r string, e error)

GetTranslation text

type Translator

type Translator interface {
	GetTranslation(s string, l string, t string) (string, error)
}

Translator interface

func NewTranslator

func NewTranslator(provider TranslatorType, props map[string]string) (Translator, error)

NewTranslator instance

type TranslatorType

type TranslatorType string

TranslatorType enum

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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