kado/kado.locale 问题修复 & 功能扩展

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

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

kado/kado.locale

最新稳定版本:1.0.1

Composer 安装命令:

composer require kado/kado.locale

包简介

PHP locale library.

README 文档

README

Locale class and some helpers

Installation

inside composer.json:

{
   "require": {
      "php": ">=8.3",
      "kado/kado.locale": "^1.0"
   }
}

Usage

If you want to use this package inside you're application include the depending composer autoload.php

The Locale

Create a new Locale instance

use \Kado\Locale\Locale;

Locale::Create(
   // The fallback locale if no other was found
   new Locale( 'de', 'AT', 'UTF-8' ),
   // Check also the URL path for a locale or language part?
   true,
   // These are the names of the parameters, accepted from $_POST, $_GET and $_SESSION
   [ 'locale', 'language', 'lang' ]
)
   ->registerAsGlobalInstance();

This creates the new Locale by checking the following places to get the required information

  • First The current URL part is checked, if it contains a valid locale string, it is used (you can disable it by setting the 2nd Create parameter to FALSE.
  • Next it checks if one of the defined request parameters (3rd parameter) is defined by $_POST, $_GET or $_SESSION
  • After that, its checked if the browser sends some information about the preferred locale/language.
  • Finally, it is checked if the system gives usable locale information.

If all this methods fail, the declared fallback locale is returned. You can also call it main locale.

Last but not least the created locale is registered as global available Locale instance. It can be accessed from other places by:

if ( Locale::HasGlobalInstance() )
{
   $locale = Locale::GetGlobalInstance();
}
else
{
   // Create the locale
   //$locale = Locale::Create( … )->registerAsGlobalInstance();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固