本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/i18n.GetResourcesPath函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetResourcesPath函數的具體用法?Golang GetResourcesPath怎麽用?Golang GetResourcesPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetResourcesPath函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewListQuotas
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,
}
}
示例2: NewCreateQuota
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,
}
}
示例3: init
func init() {
T = i18n.Init("cf/api/resources", i18n.GetResourcesPath())
}
示例4: newHttpClient
"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,
}
}
示例5:
. "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")
})
示例6: init
func init() {
T = i18n.Init(filepath.Join("cf", "ui_helpers"), i18n.GetResourcesPath())
}
示例7:
"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}}
示例8: init
func init() {
T = i18n.Init(filepath.Join("cf", "commands", "securitygroup"), i18n.GetResourcesPath())
}
示例9:
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"))
)