Beispiel #1
0
func en() {
	p := simple.New().AddLanguage("en", "English", map[string]string{
		TimeFormatRoot + ":" + DateFormat + ":" + OptionDefault: "Jan 02, 2006",
	})

	ginta.Register(p)
	internal.Activate("en")
}
Beispiel #2
0
func de() {
	p := simple.New().AddLanguage("de", "Deutsch", map[string]string{
		TimeFormatRoot + ":" + DateTimeFormat + ":" + OptionLong: "Monday, 02. January 2006, um 15:04",
		SubstitutionsResourceBundle + ":Wednesday":               "Mittwoch",
		SubstitutionsResourceBundle + ":May":                     "Mai",
	})

	ginta.Register(p)
	internal.Activate("de")
}
Beispiel #3
0
/*
	Returns a resource by simple name matching
*/
func (l Locale) GetResource(key string) (string, error) {
	locale := string(l)
	internal.Activate(locale)
	return internal.Request(locale, key, false)
}
Beispiel #4
0
/*
	Resolves a resource by its hierarchical key.
*/
func (l Locale) ResolveResource(k types.HierarchicalKey) (string, error) {
	locale := string(l)
	internal.Activate(locale)
	return internal.Request(locale, string(k), true)
}
Beispiel #5
0
/*
	Returns the combination of this resource bundle and all its parent bundles. The resources
	defined in a child are not overwritten by its parent.
*/
func (l Locale) ResolveResourceBundle(prefix string) map[string]string {
	locale := string(l)
	internal.Activate(locale)
	return internal.RequestBundle(locale, prefix, true)
}