FromCtx returns the locale from the context. The returned locale is always not nil.
(ctx context.Context)
| 20 | // FromCtx returns the locale from the context. |
| 21 | // The returned locale is always not nil. |
| 22 | func FromCtx(ctx context.Context) (*Locale, bool) { |
| 23 | val := ctx.Value(tokenKey) |
| 24 | if val == nil { |
| 25 | return new(Locale), false |
| 26 | } |
| 27 | l, ok := val.(*Locale) |
| 28 | return l, ok |
| 29 | } |
| 30 | |
| 31 | // ContextTransfer sources the locale from the sourceCtx |
| 32 | // and returns a new context based on the targetCtx |
searching dependent graphs…