Sha256: f0fc3bcb92d293ad3f114a2279662e0298c45c327b4f53a35c869b3a3a568251
Contents?: true
Size: 638 Bytes
Versions: 10
Compression:
Stored size: 638 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module Localization extend ActiveSupport::Concern included do around_action :set_locale end private def set_locale(&action) locale = params[:locale] || I18n.default_locale # Fallback to the 2 letter language code if the requested locale unavailable unless I18n.available_locales.include?(locale.to_sym) locale = locale.split("-").first end session[:locale] = locale I18n.with_locale(session[:locale], &action) rescue I18n::InvalidLocale I18n.with_locale(I18n.default_locale, &action) end end end
Version data entries
10 entries across 10 versions & 1 rubygems