MCPcopy Index your code
hub / github.com/cloudfoundry/cli / GetTranslationFunc

Function GetTranslationFunc

util/ui/i18n.go:48–63  ·  view source on GitHub ↗

GetTranslationFunc will return back a function that can be used to translate strings into the currently set locale.

(reader LocaleReader)

Source from the content-addressed store, hash-verified

46// GetTranslationFunc will return back a function that can be used to translate
47// strings into the currently set locale.
48func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) {
49 locale, err := determineLocale(reader)
50 if err != nil {
51 locale = defaultLocale
52 }
53
54 rawTranslation, err := loadAssetFromResources(locale)
55 if err != nil {
56 rawTranslation, err = loadAssetFromResources(defaultLocale)
57 if err != nil {
58 return nil, err
59 }
60 }
61
62 return generateTranslationFunc(rawTranslation)
63}
64
65// ParseLocale will return a locale formatted as "<language code>-<region
66// code>" for all non-Chinese languages. For Chinese, it will return

Callers 4

InitFunction · 0.92
i18n_test.goFile · 0.85
NewUIFunction · 0.85
NewPluginUIFunction · 0.85

Calls 3

determineLocaleFunction · 0.85
loadAssetFromResourcesFunction · 0.85
generateTranslationFuncFunction · 0.85

Tested by

no test coverage detected