func (d dateFormat) Convert(locale ginta.Locale, arg interface{}) interface{} { if time, ok := arg.(time.Time); ok { return EvaluateFormat(common.HierarchicalKey(d), locale, time) } return arg }
func doAddEntry(entry *targetResource) { if ptr := universe[entry.target]; ptr != nil { prefix, key := types.HierarchicalKey(entry.Key).Split() m, ok := ptr.entries[prefix] if !ok { m = make(bundle) ptr.entries[prefix] = m } m[key] = entry.Value } }
func work() { for { select { case l := <-registerLanguage: doRegister(&l) case activate := <-activateLanguage: doActivate(&activate) case finished := <-fetchFinished: doFetchFinished(finished) case entry := <-resourceEntry: doAddEntry(&entry) case request := <-bundleRequests: result := make(map[string]string) mergeBundles(result, types.HierarchicalKey(request.bundlePrefix), &request) request.reply <- result case request := <-requests: doFetchResource(&request) case reply := <-list: doListLanguages(reply) } } }
func doFetchResource(request *request) { if lang, ok := universe[request.code]; ok { iteration := true hierarchy := types.HierarchicalKey(request.key) for iteration { prefix, key := hierarchy.Split() if m, ok := lang.entries[prefix]; ok { if str, ok := m[key]; ok { request.reply <- reply{str, nil} return } } hierarchy = hierarchy.Parent() iteration = request.recurse && hierarchy.String() != "" } } request.reply <- reply{request.key, types.ResourceNotFoundError(request.key)} }