Skip to content

Commit

Permalink
Support .rb and .json for translation files
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed May 26, 2022
1 parent f7322dd commit d55ba8f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Localizable
def locale
@locale ||= begin
locale = ENV.fetch("BRIDGETOWN_LOCALE", config[:default_locale]).to_sym
Dir["#{in_source_dir("_locales")}/*.yml"].each do |locale_path|
Dir["#{in_source_dir("_locales")}/*.{json,rb,yml}"].each do |locale_path|
I18n.load_path << locale_path
end
I18n.available_locales = config[:available_locales]
Expand Down
8 changes: 8 additions & 0 deletions bridgetown-core/test/resources/src/_locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"en": {
"en": "English",
"test": {
"name": "Test Name"
}
}
}
4 changes: 0 additions & 4 deletions bridgetown-core/test/resources/src/_locales/en.yml

This file was deleted.

7 changes: 7 additions & 0 deletions bridgetown-core/test/resources/src/_locales/fr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
fr: {
fr: ->(_key, _i18n_options) {
"Français"
},
},
}
2 changes: 0 additions & 2 deletions bridgetown-core/test/resources/src/_locales/fr.yml

This file was deleted.

0 comments on commit d55ba8f

Please sign in to comment.