referring to
[1] This Rails Internationalization: i18n look up with nested locales directories
[2] this http://guides.rubyonrails.org/i18n.html#organization-of-locale-files
In which the rails guide only show how you could structure it but it cuts off after that. It did not mention anything about how to look up with the given file structure
So I was wondering if there is anyways to use lazy look with the file structure
consider the following directories
config/locales app/views
|locales |views
|-defaults |-fruits
|--en.yml |--apple
|--views |--banana
|---fruits |-meats
|----en.yml |--chicken
|---meat |--beef
|----en.yml
config/application.rb
config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/**/*.{rb,yml}"]
.yml
locales/views/fruits/en.yml| locales/views/meats/en.yml
|
en: | en:
produce: "Produce" | meat_section: "Meat Section" <--- shared key within folder
|
apple: | chicken:
red: "Red" | white_meat: "White Meat"
|
banana: | beef:
yellow: "Yellow" | red_meat: "Red Meat"
locales/defaults/en.yml
en:
repeat_key:
market: "Market" <------- shared key across folders
Is there any way that i can do this ? or anything close to that ??
In views/fruits/apple.html.haml
= t('.red') <------- unique key in apple
= t('produce') <------- shared key within fruits folder
= t('repeat_key.maket') <------- repeat key across fruits and meat folders
I know that fact that the following code will work but since I am in the apple directory, there must be a way to use the lazy look up for the unique key.
In views/fruits/apple.html.haml
= t('apple.red') <------- unique key in apple
= t('produce') <------- shared key within fruits folder
= t('repeat_key.maket') <------- repeat key across fruits and meat folders
I think that if this is possible. It can minimize duplicate keys and if we need extra alias to be added, we can add it when it's necessary since I believe most translation team charge per words