agopaul/zf-linguo 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agopaul/zf-linguo

Composer 安装命令:

composer require agopaul/zf-linguo

包简介

Zend Framework 2 Module that provides multi-language routes capability

README 文档

README

True multi-lingual routes support for ZF2

This zf2 module helps dealing with fully-localized URLS

Example

Consider you have an action with two completely localized URLs

GET /en/contacts
GET /it/contatti

module/Application/config/config.php

<?php
return array(
	"router" => array(
		"router_class" => "Zend\Mvc\Router\Http\TranslatorAwareTreeRouteStack", // Add this
		'routes' => => array(
	
			// Route
			'contacts' => array(
				'type' => 'Linguo\Library\Mvc\Router\Http\MultiLangSegment', // Change this
				'options' => array(
					'route' => '/:lang/{contacts}',
					'defaults' => array(
						'__NAMESPACE__' => 'Application\Controller',
						'controller' => 'Site',
						'action' => 'contacts'
					),
				),
			),
			
		),
	),
);

Configuration

config/application.config.php

<?php
return array(
	'modules' => array(
		'Linguo',
	
		// Your modules here
	)
)

config/autoload/linguo.php

"linguo" => array(
	"langMap" => array(
		// locale - slug pair
		"en_US" => "en",
		"it_IT" => "it",
	)
)

module/Application/Module.php

<?php
/**
 * On bootstrap
 * @param MvcEvent $e
 */
public function onBootstrap(MvcEvent $e){
	
	/* @var $eventManager EventManager */
	$eventManager = $e->getApplication()->getEventManager();
	
	// Set translator locale based on the request URL
	$eventManager->attach($this->getServiceLocator()->get('Linguo\Library\Translator\SetLocaleFromUrlStrategy'));
}

Limitations

  • The language parameter must be named :lang
  • The route isn't very optimized (for conservative reasons), it might be slower than the Segment route.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-07-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固