Actionpack-page_caching with i18n


I need to get some pages to be super fast and actionpack-page_caching is a doing the job but I also need to get i18n.

So I am executing the translate in a js controller via the gem i18n-js, so theorically, the translation is excute on the client side after it get the page.

But it’s not working, is someone has encountered a similar problem: cache page + i18n ?

Best regards.

I don’t know actionpack-page_caching and we don’t use i18n-js as our translation is performed server-side. We override cache as shown below to automatically include the locale in the key (don’t know where the idea was initially taken from):

module CacheHelper
  # Always using current I18n.locale to cache things.
  def cache(name = {}, options = {}, &block)
    name_with_locale = [name].flatten << I18n.locale.to_s
    super(name_with_locale, options, &block)

Ok, thanks to answer.