本文整理匯總了Golang中github.com/nttlabs/cli/cf/i18n.Init函數的典型用法代碼示例。如果您正苦於以下問題:Golang Init函數的具體用法?Golang Init怎麽用?Golang Init使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Init函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestEnvironmentVariableGroups
func TestEnvironmentVariableGroups(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
RunSpecs(t, "EnvironmentVariableGroups Suite")
}
示例2: TestStaging
func TestStaging(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
RunSpecs(t, "Staging Suite")
}
示例3: TestSecurityGroupSpaces
func TestSecurityGroupSpaces(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
RunSpecs(t, "SecurityGroupSpaces Suite")
}
示例4: TestCopyApplicationSource
func TestCopyApplicationSource(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
RunSpecs(t, "CopyApplicationSource Suite")
}
示例5: TestApp
func TestApp(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_1")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "fixtures", "plugins"), "test_2")
RunSpecs(t, "App Suite")
}
示例6: TestPlugin
func TestPlugin(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_help")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push_short_name")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_1")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_2")
plugin_builder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "empty_plugin")
RunSpecs(t, "Plugin Suite")
}
示例7: setupDependencies
func setupDependencies() (deps *cliDependencies) {
deps = new(cliDependencies)
deps.teePrinter = terminal.NewTeePrinter()
deps.termUI = terminal.NewUI(os.Stdin, deps.teePrinter)
deps.manifestRepo = manifest.NewManifestDiskRepository()
errorHandler := func(err error) {
if err != nil {
deps.termUI.Failed(fmt.Sprintf("Config error: %s", err))
}
}
deps.configRepo = core_config.NewRepositoryFromFilepath(config_helpers.DefaultFilePath(), errorHandler)
deps.pluginConfig = plugin_config.NewPluginConfig(errorHandler)
i18n.T = i18n.Init(deps.configRepo)
terminal.UserAskedForColors = deps.configRepo.ColorEnabled()
terminal.InitColorSupport()
if os.Getenv("CF_TRACE") != "" {
trace.Logger = trace.NewLogger(os.Getenv("CF_TRACE"))
} else {
trace.Logger = trace.NewLogger(deps.configRepo.Trace())
}
deps.gateways = map[string]net.Gateway{
"auth": net.NewUAAGateway(deps.configRepo, deps.termUI),
"cloud-controller": net.NewCloudControllerGateway(deps.configRepo, time.Now, deps.termUI),
"uaa": net.NewUAAGateway(deps.configRepo, deps.termUI),
}
deps.apiRepoLocator = api.NewRepositoryLocator(deps.configRepo, deps.gateways)
return
}
示例8:
var _ = Describe("i18n.Init() function", func() {
var (
oldResourcesPath string
configRepo core_config.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")
})
It("Panics if the locale is not valid", func() {
configRepo.SetLocale("abc_def")
init := func() { i18n.Init(configRepo) }
示例9:
configRepo core_config.ReadWriter
)
BeforeEach(func() {
i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures")
configRepo = testconfig.NewRepositoryWithDefaults()
})
Describe("When a user has a locale configuration set", func() {
Context("creates a valid T function", func() {
BeforeEach(func() {
configRepo.SetLocale("en_US")
})
It("returns a usable T function for simple strings", func() {
T := i18n.Init(configRepo)
Ω(T).ShouldNot(BeNil())
translation := T("Hello world!")
Ω("Hello world!").Should(Equal(translation))
})
It("returns a usable T function for complex strings (interpolated)", func() {
T := i18n.Init(configRepo)
Ω(T).ShouldNot(BeNil())
translation := T("Deleting domain {{.DomainName}} as {{.Username}}...", map[string]interface{}{"DomainName": "foo.com", "Username": "Anand"})
Ω("Deleting domain foo.com as Anand...").Should(Equal(translation))
})
})
})