Skip to content

Commit

Permalink
* Expose translations with option to perform initalization
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Sep 21, 2018
1 parent 85b1796 commit ae47118
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/i18n/backend/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ def reload!
super
end

def translations(do_init: false)
# To avoid returning empty translations,
# call `init_translations`
init_translations if do_init && !initialized?

@translations ||= {}
end

protected

def init_translations
load_translations
@initialized = true
end

def translations
@translations ||= {}
end

# Looks up a translation from the translations hash. Returns nil if
# either key is nil, or locale, scope or key do not exist as a key in the
# nested translations hash. Splits keys or scopes containing dots
Expand Down

0 comments on commit ae47118

Please sign in to comment.