当前位置: 首页>>代码示例>>Golang>>正文


Golang i18n.GetResourcesPath函数代码示例

本文整理汇总了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,
	}
}
开发者ID:palakmathur,项目名称:cli,代码行数:13,代码来源:quotas.go

示例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,
	}
}
开发者ID:palakmathur,项目名称:cli,代码行数:13,代码来源:create_quota.go

示例3: init

func init() {
	T = i18n.Init("cf/api/resources", i18n.GetResourcesPath())
}
开发者ID:GABONIA,项目名称:cli,代码行数:3,代码来源:i18n_init.go

示例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,
	}
}
开发者ID:GABONIA,项目名称:cli,代码行数:30,代码来源:http_client.go

示例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")
		})
开发者ID:matanzit,项目名称:cli,代码行数:30,代码来源:init_unix_test.go

示例6: init

func init() {
	T = i18n.Init(filepath.Join("cf", "ui_helpers"), i18n.GetResourcesPath())
}
开发者ID:GABONIA,项目名称:cli,代码行数:3,代码来源:i18n_init.go

示例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}}
开发者ID:jacopen,项目名称:cli,代码行数:31,代码来源:app.go

示例8: init

func init() {
	T = i18n.Init(filepath.Join("cf", "commands", "securitygroup"), i18n.GetResourcesPath())
}
开发者ID:jacopen,项目名称:cli,代码行数:3,代码来源:i18n_init.go

示例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"))
)
开发者ID:GABONIA,项目名称:cli,代码行数:30,代码来源:bytes.go


注:本文中的github.com/cloudfoundry/cli/cf/i18n.GetResourcesPath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。