Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8140455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:10:30+00:00 2026-06-06T12:10:30+00:00

I am creating a multi lingual application using ZF2.. and cannot determine how to

  • 0

I am creating a multi lingual application using ZF2.. and cannot determine how to add a part URL which will form the base of each URL regardless of modules.

http://localhost/en/us/application/index/index/

I totally understand how to configure /[:namespace[/:controller[/:action]]] using DI

http://localhost/application/index/index/
http://localhost/guestbook/index/index/
http://localhost/forum/index/index/

What I do not understand is how to configure a Part route which will be the base for all routes.. In ZF1 I used Route Chaining to achieve this..

So I need to configure a Part route of /[:lang[/:locale]] which applies site wide and then let the module configure /[:namespace[/:controller[/:action]]] or any other route necessary..

http://localhost/en/us/application/index/index/
http://localhost/zh/cn/application/index/index/
http://localhost/en/uk/forum/index/index/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:10:31+00:00Added an answer on June 6, 2026 at 12:10 pm

    I think what you are looking for is the child_routes configuration key. Take a look at how ZfcUser configures it’s routing (here): it creates a base Literal route (/user) and then chains the sub-routes (/user/login, etc) onto it via the child_routes array.

    I think something like this will do the trick for you:

    'router' => array(
        'routes' => array(
            'myapp' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/[:lang[/:locale]]',
                    'defaults' => array(
                        'lang'   => 'en',
                        'locale' => 'us',
                    ),
                ),
                'may_terminate' => false,
                'child_routes' => array(
                    'default' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/[:controller[/:action]]',
                            'constraints' => array(
                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                            'controller' => 'index',
                            'action'     => 'index',
                        ),
                    ),
                ),
            ),
        ),
    ),
    

    Then in your controller you could do this to get the lang and locale:

    $this->params()->fromRoute('lang');
    $this->params()->fromRoute('locale');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a multi-threaded application in which each thread will appear as a
I'm creating a multi-tenant ASP.NET application using NHibernate (shared schema). I had intended to
I'm creating a multi-part form in the style that Ryan Bates describes here: http://railscasts.com/episodes/217-multistep-forms
I'm creating a multi-part web form in ASP.NET that uses Panels for the different
We are starting to create an application using JavaScript and HTML5 which will use
Background: I am creating a multi-language web application using Flash-builder 4. The menus and
We are creating a multi-tenant ASP.NET MVC application that will be deployed onto Windows
I'm creating a multi-threaded application in C using Linux. I'm unsure whether I should
I am thinking of creating a multi-platform portable C++ server-client application. Is it even
I'm starting my hand at creating a multi-player game using HTML 5 / Javascript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.