代码之家  ›  专栏  ›  技术社区  ›  costa

Zend翻译路线

  •  7
  • costa  · 技术社区  · 8 年前

    例子:

    用于/de的路线

    $routes['industry'] = array(
        'route' => 'branche/:type',
        'defaults' => array(
            'module' => 'default',
            'controller' => 'index',
            'action' => 'branche',
            'type' => 'automobil'
        ),
        'reqs' => array(
            'type' => '(automobil|textil)'
        )
    );
    

    路线

    $routes['industry'] = array(
        'route' => 'industry/:type',
        'defaults' => array(
            'module' => 'default',
            'controller' => 'index',
            'action' => 'branche',
            'type' => 'car'
        ),
        'reqs' => array(
            'type' => '(car|textile)'
        )
    );
    

    2 回复  |  直到 8 年前
        1
  •  1
  •   Emiliano    8 年前

    我看到两条不同的路线 通常,国际化在页面上,但不在url上

    让我明确一点,您保留您的url,并且在url中有一个参数,您知道页面的语言,因此

    $routes['industry'] = array(
        'route' => 'industry/:lang/:type',
        'defaults' => array(
            'module' => 'default',
            'controller' => 'index',
            'action' => 'branche',
            'type' => 'car',
            'lang' => 'en'
        ),
        'reqs' => array(
            'lang' => '(en|de)',
            'type' => '(car|textile)'
        )
    );
    

    更改url的另一种方法是:

    $routes['industry'] = array(
        'route' => ':industry/:type',
        'defaults' => array(
            'module' => 'default',
            'controller' => 'index',
            'action' => 'branche',
            'type' => 'car',
            'industry' => 'industry'
        ),
        'reqs' => array(
            'industry' => '(industry|branche)',
            'type' => '(car|textile)'
        )
    );