4 ms·
Ahhh....right. I haven't used it much...but that's an interesting take on it. I've seen it used for date & time localization - not for such heavy copy usage l
by marcamillion 13y ago
Ahhh....right.
I haven't used it much...but that's an interesting take on it.
I've seen it used for date & time localization - not for such heavy copy usage like this.
Do you profile the site - with say Rack-Mini-Profiler to see what the performance hit of using I18n like that would be? I don't see it in the Gemfile, but maybe you are using something else to see what the hit of all those choices are on your performance?
It seems that it may be an extra tax - even though it is clever and I like it...just curious what the cost is...and would love to know other non-I18n ways to achieve that, with say ERB.
- robotmay 13y agoI must admit that I haven't looked into the speed side of it too much! I suspect it's not too bad as the YAML file is loaded once on initialisation into a hash, which the t() function then retrieves the values from. I'm not sure if that differs when using a database backend. One benefit of using Slim here is that it's a bit faster than ERB/HAML (as you can see in my token biased benchmarks: https://speakerdeck.com/robotmay/a-simple-introduction-to-effective-caching-in-ruby-on-rails?slide=22 https://speakerdeck.com/robotmay/a-simple-introduction-to-ef...) so it probably negates any extra time that might be added by using locales. There's two main reasons I use locales so heavily: 1. I like my views to be small and largely free of logic 2. I'd like to translate the site into other languages, and using locales from the start makes it much simpler!