pragmarx / glottos
A PHP 5.3+ 在线翻译/本地化系统
v1.5.3
2017-01-31 02:39 UTC
Requires
- php: >=5.3.7
- illuminate/console: ~4|~5
- illuminate/filesystem: ~4|~5
- illuminate/support: ~4|~5
- symfony/translation: ~2|~3
Requires (Dev)
- mockery/mockery: 0.8.0
This package is auto-updated.
Last update: 2024-09-21 19:36:28 UTC
README
为 Laravel 网页艺术家提供的在线翻译/本地化系统
查看Glottos Admin,这是一个使用 Glottos 构建的具有完整功能的站点翻译系统。
快速了解您可以使用它做什么
// Use the Facade to set a locale Glottos::setLocale('pt_BR'); // And just use it Glottos::translate('Laravel is a PHP Framework'); // There's a helper g('Laravel is a PHP Framework'); // Choose a particular locale Glottos::translate('Laravel is a PHP Framework', 'pt_BR') // or Glottos::translate('Laravel is a PHP Framework', 'pt-br') // Glottos let you choose between keys and natural language: Glottos::translate('key::home.describe.laravel') Glottos::translate('natural::Laravel is a PHP Framework') // or you can just define your default as natural and use: Glottos::translate('Laravel is a PHP Framework') // It will break your paragraphs in sentences Glottos::translate('Laravel is a PHP Framework. Laravel was written by Taylor Otwell.') // To not repeat itself, it will store those two sentences in your database: 'Laravel is a PHP Framework' 'Laravel was written by Taylor Otwell' // Removing punctuation and special chars. // With a simple blade trick Blade::extend(function ($view) { return preg_replace( '/{{\'((.|\s)*?)\'}}/', '<?php echo Glottos::translate("$1"); ?>', $view ); }); // You can use it beautifully in your Views: <p>{{'Laravel is a PHP Framework'}}</p> // You can still use the Lang Facade, Glottos has a compatible one Lang::trans('Photography') // And use choice Lang::choice('Photography|Photographies', 100, array(), 'pt_BR') Glottos::choice('Photography|Photographies', 100, array(), 'pt_BR') // And dozens of other features, like importing your current language files
这个包背后的想法非常简单:您需要您的网络应用快速成为多语言,因此您最好在线将其全部翻译,并得到同事或社区的帮助。
模式
基本上,Glottos 将创建并有时填充一些表格,用于
- 国家 - 127
- 语言 - 129
- 地区 - 323 - 每个地区都有其适当的区域语言名称
- 消息 - (存储主要消息的哈希值)
- 翻译 - 每个消息和地区有一行
以下是 Laravel 的消息在管理网站上的存储视图
安装
要求
- 任何 PHP 5.3.7+ 版本都应适用
- [可选] PHPUnit 来执行测试套件
框架
由于 Glottos 依赖于数据层,因此它是一个 Laravel 4.x 准备好的包,但它被编码成尽可能无歧义,因此您可以在自己的框架上创建新驱动程序并使用它。您甚至可以发送 PR 来将其添加到主代码。
使用 Composer
composer require pragmarx/glottos dev-master
完成此操作后,将服务提供者添加到您的 app/config/app.php 中
'PragmaRX\Glottos\Vendor\Laravel\ServiceProvider',
迁移 Glottos 表
php artisan migrate --package=pragmarx/glottos
导入您的当前语言文件
php artisan glottos:import
然后您就可以使用了。享受吧!
待办事项
- 为它添加一个真正的缓存层。
- 添加更多框架和数据访问驱动程序。
作者
Antonio Carlos Ribeiro - acr@antoniocarlosribeiro.com - http://twitter.com/iantonioribeiro
### 许可证Glottos 在 MIT 许可证下发布 - 请参阅 LICENSE
文件以获取详细信息
贡献
欢迎提交拉取请求和问题。