Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package timeago |
||
2 | |||
3 | type Config struct { |
||
4 | // Language is an ISO 639 language code like en, ru, de, nl, etc. |
||
5 | // If Language is not set it will default to English "en". |
||
6 | Language string |
||
7 | |||
8 | // Location is the timezone location neeed for parsing |
||
9 | // string date like "2019-01-01 00:00:00" to time.Time. |
||
10 | // If Location is not set it will default to the server's. |
||
11 | // Example: "America/New_York", "Asia/China" |
||
12 | Location string |
||
13 | |||
14 | // Translations is a slice of language sets that can be used to |
||
15 | // overwrite the default translations. Read more about it in the docs |
||
16 | // https://time-ago.github.io/configurations.html#overwrite-translations |
||
17 | Translations []LangSet |
||
18 | } |
||
19 | |||
20 | // NewConfig creates a new Config instance with the given language, location |
||
21 | // and language sets to overwrite the default translations. |
||
22 | func NewConfig(lang, loc string, langSets []LangSet) *Config { |
||
23 | return &Config{ |
||
24 | Language: lang, |
||
25 | Location: loc, |
||
26 | Translations: langSets, |
||
27 | } |
||
28 | } |
||
29 | |||
30 | // IsLocationProvided check if the location is privided by the user |
||
31 | func (c Config) IsLocationProvided() bool { |
||
32 | return c.Location != "" |
||
33 | } |
||
34 |