承接 technicalguru/i18n 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

technicalguru/i18n

Composer 安装命令:

composer require technicalguru/i18n

包简介

Provides localization features for PHP apps

README 文档

README

Provides localization features for PHP apps. It reads a local i18n file for your application and provides localized values for keys.

License

This project is licensed under GNU LGPL 3.0.

Installation

By Composer

composer install technicalguru/i18n

By Package Download

You can download the source code packages from GitHub Release Page

How to use

Create a localization file

Create a file i18n.php somewhere where it can be accessed from your application.

<?php

/** Put here your language translations */
return array(
	'welcome' => array(
		'de' => 'Willkommen!',
		'en' => 'Welcome!',
	),
);

Initialize I18N

Tell I18N where it will find your localizations and what your default language is.

use TgI18n\I18n;

I18N::$i18nFile        = '/my/path/to/i18n.php';
I18N::$defaultLangCode = 'de';

Default Initialization

You don't need to tell I18N where to find your localizations when they exists in one of these places. The file needs to be named i18n.php.

  • Web Context Document Root as defined by $_SERVER['CONTEXT_DOCUMENT_ROOT']
  • Web Document Root as defined by $_SERVER['DOCUMENT_ROOT']
  • Current directory of your running script file (that is the one being executed)

You don't need to initialize the default language code, when it is en.

Translating Values

Now you are setup to use your localizations:

use TgI18n\I18n;

echo I18N::_('welcome');
echo I18N::_('welcome', 'en');
echo I18N::_('welcome', 'de');

The _($key) static method always returns a value. If the given key cannot be found then the key itself will be returned.

If you prefer to have NULL returned, then use __($key):

use TgI18n\I18n;

echo I18N::__('welcome');
echo I18N::__('welcome', 'en');
echo I18N::__('welcome', 'de');

Contribution

Report a bug, request an enhancement or pull request at the GitHub Issue Tracker.

technicalguru/i18n 适用场景与选型建议

technicalguru/i18n 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.51k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「localization」 「internationalization」 「languages」 「multi-language」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 technicalguru/i18n 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 technicalguru/i18n 我们能提供哪些服务?
定制开发 / 二次开发

基于 technicalguru/i18n 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2020-11-12