Skip to content

Commit

Permalink
Update constructor (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
bos-hieu authored Feb 9, 2022
1 parent 372387d commit 1f815a4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ var atI18n GinI18n

// newI18n ...
func newI18n(opts ...Option) {
// init default value
ins := &ginI18nImpl{
getLngHandler: defaultGetLngHandler,
}
ins.setBundle(defaultBundleConfig)
// init ins
ins := &ginI18nImpl{}

// overwrite default value by options
// set ins property from opts
for _, opt := range opts {
opt(ins)
}

// if bundle isn't constructed then assign it from default
if ins.bundle == nil {
ins.setBundle(defaultBundleConfig)
}

// if getLngHandler isn't constructed then assign it from default
if ins.getLngHandler == nil {
ins.getLngHandler = defaultGetLngHandler
}

atI18n = ins
}

Expand Down

0 comments on commit 1f815a4

Please sign in to comment.