( locale string, )
| 1244 | } |
| 1245 | |
| 1246 | func (env *CollationEnvironment) getCacheEntry( |
| 1247 | locale string, |
| 1248 | ) (collationEnvironmentCacheEntry, error) { |
| 1249 | entry, ok := env.cache[locale] |
| 1250 | if !ok { |
| 1251 | if env.cache == nil { |
| 1252 | env.cache = make(map[string]collationEnvironmentCacheEntry) |
| 1253 | } |
| 1254 | tag, err := language.Parse(locale) |
| 1255 | if err != nil { |
| 1256 | err = errors.NewAssertionErrorWithWrappedErrf(err, "failed to parse locale %q", locale) |
| 1257 | return collationEnvironmentCacheEntry{}, err |
| 1258 | } |
| 1259 | |
| 1260 | entry = collationEnvironmentCacheEntry{locale, collate.New(tag)} |
| 1261 | env.cache[locale] = entry |
| 1262 | } |
| 1263 | return entry, nil |
| 1264 | } |
| 1265 | |
| 1266 | // NewDCollatedString is a helper routine to create a *DCollatedString. Panics |
| 1267 | // if locale is invalid. Not safe for concurrent use. |
no test coverage detected