You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.
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"
Then the template is much cleaner:
<h1>{{ copy.header | at }}</h1>
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: