-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I18n localisation files do not support subdirectories. #598
Comments
@robodinoshaun That makes sense to me. Would you be willing to submit a PR with the proposed fix (I'm fine with either option)? |
Sure, I should be able to get around to that soon. A loosely related suggestion would be updating the fallback chain for regional language variants to include the base locale (e.g. fr-CN -> fr -> en rather than simply fr-CN -> en) |
@robodinoshaun That seems reasonable. Out of curiosity, is that something Rails does automatically? Or is it a manual config step? |
@jaredcwhite yeah, it does. |
@jaredcwhite Actually, it's a function of ruby-i18n itself.
This doesn't include the default locale, but Rails has a config setting that ultimately sets
|
@robodinoshaun Interesting! I'll have to take a second look at this along with #607…the sort of wonky looking code that was in there for fallbacks I had added for a reason, but now I can't for the life of me remember the reason! (should have added a comment!) |
Interesting. If there IS a reason it was necessary, I would be curious as to what it is. In which case I guess the required change would be to add the top-level directly to the code as written.
The tests in the PR should still prove useful either way, I think. |
For reference, we put this into a custom plugin builder. But supporting sub-dirs by default would be neat. # plugins/builders/custom_setup.rb
class Builders::CustomSetup < SiteBuilder
def build
I18n.load_path << Dir["#{site.source}/_locales/**/*.yml"]
end
end |
I think this is addressed now in v1.2. |
Awesome! @jaredcwhite |
Locale files have to be directly in src/_locales to work (e.g. src/_locales/en.yml), which limits the ability to organise multiple files.
It looks like changing the load path in localizable.rb from
to
would resolve this, or even one-lining it as Rails does with
I18n.load_path += Dir["#{in_source_dir("_locales")}/**/*.{json,rb,yml}"]
.The text was updated successfully, but these errors were encountered: