Exemplo n.º 1
0
func NewListQuotas(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *ListQuotas) {
	t, err := i18n.Init("quota", i18n.GetResourcesPath())
	if err != nil {
		ui.Failed(err.Error())
	}

	return &ListQuotas{
		ui:        ui,
		config:    config,
		quotaRepo: quotaRepo,
		T:         t,
	}
}
Exemplo n.º 2
0
func NewCreateQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) CreateQuota {
	t, err := i18n.Init("quota", i18n.GetResourcesPath())
	if err != nil {
		ui.Failed(err.Error())
	}

	return CreateQuota{
		ui:        ui,
		config:    config,
		quotaRepo: quotaRepo,
		T:         t,
	}
}
Exemplo n.º 3
0
func init() {
	T = i18n.Init("cf/api/resources", i18n.GetResourcesPath())
}
Exemplo n.º 4
0
func init() {
	T = i18n.Init("cf/commands/application", i18n.GetResourcesPath())
}
Exemplo n.º 5
0
	"github.com/cloudfoundry/cli/cf/errors"
	"github.com/cloudfoundry/cli/cf/terminal"
	"github.com/cloudfoundry/cli/cf/trace"
	"net"
	"net/http"
	"net/http/httputil"
	"net/url"
	"regexp"
	"strings"
	"time"

	"github.com/cloudfoundry/cli/cf/i18n"
)

var (
	t                        = i18n.Init("cf/net", i18n.GetResourcesPath())
	PRIVATE_DATA_PLACEHOLDER = t("[PRIVATE DATA HIDDEN]")
)

func newHttpClient(trustedCerts []tls.Certificate, disableSSL bool) *http.Client {
	tr := &http.Transport{
		TLSClientConfig: NewTLSConfig(trustedCerts, disableSSL),
		Proxy:           http.ProxyFromEnvironment,
	}

	return &http.Client{
		Transport:     tr,
		CheckRedirect: PrepareRedirect,
	}
}
Exemplo n.º 6
0
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("i18n.Init() function", func() {
	var (
		oldResourcesPath string
		configRepo       configuration.ReadWriter

		T go_i18n.TranslateFunc
	)

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		oldResourcesPath = i18n.GetResourcesPath()
		i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures")
	})

	JustBeforeEach(func() {
		T = i18n.Init(configRepo)
	})

	Describe("When a user has a locale configuration set", func() {
		It("panics when the translation files cannot be loaded", func() {
			i18n.Resources_path = filepath.Join("should", "not", "be_valid")
			configRepo.SetLocale("en_us")

			init := func() { i18n.Init(configRepo) }
			Ω(init).Should(Panic(), "loading translations from an invalid path should panic")
		})
Exemplo n.º 7
0
func init() {
	T = i18n.Init(filepath.Join("cf", "ui_helpers"), i18n.GetResourcesPath())
}
Exemplo n.º 8
0
func init() {
	T = i18n.Init(filepath.Join("cf", "commands", "space"), i18n.GetResourcesPath())
}
Exemplo n.º 9
0
Arquivo: app.go Projeto: jacopen/cli
	"strings"
	"time"

	"github.com/cloudfoundry/cli/cf"
	"github.com/cloudfoundry/cli/cf/command_metadata"
	"github.com/cloudfoundry/cli/cf/command_runner"
	"github.com/cloudfoundry/cli/cf/errors"
	"github.com/cloudfoundry/cli/cf/terminal"
	"github.com/cloudfoundry/cli/cf/trace"
	"github.com/codegangsta/cli"

	"github.com/cloudfoundry/cli/cf/i18n"
)

var (
	t               = i18n.Init("cf/app", i18n.GetResourcesPath())
	appHelpTemplate = `{{.Title "` + t("NAME:") + `"}}
   {{.Name}} - {{.Usage}}

{{.Title "` + t("USAGE:") + `"}}
   ` + t("[environment variables]") + ` {{.Name}} ` + t("[global options] command [arguments...] [command options]") + `

{{.Title "` + t("VERSION:") + `"}}
   {{.Version}}

{{.Title "` + t("BUILD TIME:") + `"}}
   {{.Compiled}}
   {{range .Commands}}
{{.SubTitle .Name}}{{range .CommandSubGroups}}
{{range .}}   {{.Name}} {{.Description}}
{{end}}{{end}}{{end}}
Exemplo n.º 10
0
func init() {
	T = i18n.Init("cf/configuration", i18n.GetResourcesPath())
}
Exemplo n.º 11
0
func init() {
	T = i18n.Init("cf/manifest", i18n.GetResourcesPath())
}
Exemplo n.º 12
0
func init() {
	T = i18n.Init("cf/commands/domain", i18n.GetResourcesPath())
}
Exemplo n.º 13
0
func init() {
	T = i18n.Init("cf/commands/servicebroker", i18n.GetResourcesPath())
}
Exemplo n.º 14
0
func init() {
	T = i18n.Init("cf/commands/organization", i18n.GetResourcesPath())
}
Exemplo n.º 15
0
func init() {
	T = i18n.Init(filepath.Join("cf", "commands", "serviceauthtoken"), i18n.GetResourcesPath())
}
Exemplo n.º 16
0
func init() {
	T = i18n.Init("cf/actors", i18n.GetResourcesPath())
}
Exemplo n.º 17
0
func init() {
	T = i18n.Init("cf/formatters", i18n.GetResourcesPath())
}
Exemplo n.º 18
0
func init() {
	T = i18n.Init("cf/commands/route", i18n.GetResourcesPath())
}
Exemplo n.º 19
0
func init() {
	T = i18n.Init(filepath.Join("cf", "terminal"), i18n.GetResourcesPath())
}
Exemplo n.º 20
0
func init() {
	T = i18n.Init("cf/trace", i18n.GetResourcesPath())
}
Exemplo n.º 21
0
func init() {
	T = i18n.Init("cf/api/strategy", i18n.GetResourcesPath())
}
Exemplo n.º 22
0
func init() {
	T = i18n.Init("cf/requirements", i18n.GetResourcesPath())
}
Exemplo n.º 23
0
func init() {
	T = i18n.Init("cf/net", i18n.GetResourcesPath())
}
Exemplo n.º 24
0
func init() {
	T = i18n.Init("cf/command_factory", i18n.GetResourcesPath())
}
Exemplo n.º 25
0
func init() {
	T = i18n.Init("cf/api/authentication", i18n.GetResourcesPath())
}
Exemplo n.º 26
0
func init() {
	T = i18n.Init("cf/command_runner", i18n.GetResourcesPath())
}
Exemplo n.º 27
0
func init() {
	T = i18n.Init(filepath.Join("cf", "commands", "securitygroup"), i18n.GetResourcesPath())
}
Exemplo n.º 28
0
Arquivo: bytes.go Projeto: GABONIA/cli
	if len(parts) < 3 {
		return 0, invalidByteQuantityError
	}

	value, err := strconv.ParseUint(parts[1], 10, 0)
	if err != nil || value < 1 {
		return 0, invalidByteQuantityError
	}

	var bytes uint64
	unit := strings.ToUpper(parts[2])
	switch unit {
	case "T":
		bytes = value * TERABYTE
	case "G":
		bytes = value * GIGABYTE
	case "M":
		bytes = value * MEGABYTE
	case "K":
		bytes = value * KILOBYTE
	}

	return bytes / MEGABYTE, nil
}

var (
	bytesPattern             *regexp.Regexp = regexp.MustCompile(`(?i)^(-?\d+)([KMGT])B?$`)
	t                                       = i18n.Init("cf/formatters", i18n.GetResourcesPath())
	invalidByteQuantityError                = errors.New(t("Byte quantity must be a positive integer with a unit of measurement like M, MB, G, or GB"))
)