When I was first familiarizing myself with how to use it, I felt that the liquid filter was kind of clumsy because it was necessary to provide each of the language variables individually. I thought that it would be better to be able to pass one variable and let the plugin decide which translation to use based on the filename. I'm no Ruby coder, but I messed around and came up with this and it seems to work:
def auto_translate(*translations)
if !translations[0][lang].nil?
translations[0][lang]
else
translations[0]["en"]
end
end
alias_method :at, :auto_translate
I structure my language variables in my front matter like so:
copy:
header:
en: "blah blah blah"
fr: "yadda yadda yadda"
hey, great idea! what about amending translate_lang (and by extension translate) to accept either an array or a hash? this would give you the same syntax, but you'd still use the same method t.
Thanks for the excellent localization plugin.
When I was first familiarizing myself with how to use it, I felt that the liquid filter was kind of clumsy because it was necessary to provide each of the language variables individually. I thought that it would be better to be able to pass one variable and let the plugin decide which translation to use based on the filename. I'm no Ruby coder, but I messed around and came up with this and it seems to work:
I structure my language variables in my front matter like so:
Then the template is much cleaner: