lib/route_translator/translator/path.rb
# Translates a path and adds the locale prefix.
Translates a path and adds the locale prefix.
Translates a path and adds the locale prefix .
def translate(path, locale, scope)
        new_path = path.dup
        final_optional_segments = new_path.slice!(%r{(\([^\/]+\))$})
        translated_segments = new_path.split('/').map do |seg|
          seg.split('.').map { |phrase| Segment.translate(phrase, locale, scope) }.join('.')
        end
        translated_segments.reject!(&:empty?)
        if display_locale?(locale) && !locale_param_present?(new_path)
          translated_segments.unshift(locale_segment(locale))
        end
        joined_segments = translated_segments.join('/')
        "/#{joined_segments}#{final_optional_segments}".gsub(%r{\/\(\/}, '(/')
      end
def translate ( path , locale , scope ) new_path = path . dup final_optional_segments = new_path . slice! ( %r{ ( \( [^ \/ ]+ \) )$ } ) translated_segments = new_path . split ( '/' ) . map do | seg | seg . split ( '.' ) . map { | phrase | Segment . translate ( phrase , locale , scope ) } . join ( '.' ) end translated_segments . reject! ( & :empty? ) if display_locale? ( locale ) && ! locale_param_present? ( new_path ) translated_segments . unshift ( locale_segment ( locale ) ) end joined_segments = translated_segments . join ( '/' ) "/#{joined_segments}#{final_optional_segments}" . gsub ( %r{ \/ \( \/ } , '(/' ) end
Translates a path and adds the locale prefix.
Translates a path and adds the locale prefix .
path
<not_specific>
locale
<not_specific>
scope
<not_specific>