class Maglev::ExtractLocale
and set the Translatable.current_locale accordingly
Extract the locale from the current HTTP request
def call
def call locale, path = extract_locale Maglev::I18n.current_locale = locale params[:path] = path [path, locale] end
def default_locale
def default_locale locales.first end
def extract_locale
def extract_locale path = params[:path] || 'index' segments = path.split('/') return [default_locale, path] unless locales.include?(segments[0]&.to_sym) [segments.shift, segments.empty? ? 'index' : segments.join('/')] end