thinktomorrow/squanto

开发期间及之后用于静态 Laravel 翻译的文本管理器

3.0.3 2024-01-08 10:30 UTC

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

在开发期间及之后管理您的 Laravel 应用程序的静态翻译。Squanto 的名字来源于一位最早的 土著美国翻译员,是一种有见地的数据库中管理翻译的方法。

注意:此包仍在开发中,API 将会发生变化。尽管如此,请尝试使用此包,因为反馈非常受欢迎!

要求

  • php >= 7.4.7
  • Laravel >= 8.0

安装

通过 Composer

$ composer require thinktomorrow/squanto

设置

此包的服务提供程序将由 Laravel 自动发现。请注意,有两个提供程序:一个是通用包服务提供程序,还有一个是为管理器浏览器 UI 分离的。

运行迁移。这将在您的数据库中添加一个名为 squanto_lines 的表。

$ php artisan migrate

接下来,发布配置文件。

    php artisan vendor:publish --tag=squanto-config

在配置中,通过 Squanto 设置您希望维护的不同语言环境。大多数其他配置设置都是合理的默认值,应该可以正常工作。

管理界面

路由

添加以下路由。这些是查看和编辑翻译的路由定义。请确保您添加了必要的认证中间件。

Route::get('translations/{id}/edit', [\Thinktomorrow\Squanto\Manager\Http\ManagerController::class, 'edit'])->name('squanto.edit');
Route::put('translations/{id}', [\Thinktomorrow\Squanto\Manager\Http\ManagerController::class, 'update'])->name('squanto.update');
Route::get('translations', [\Thinktomorrow\Squanto\Manager\Http\ManagerController::class, 'index'])->name('squanto.index');

所见即所得编辑器

需要 'redactor' 编辑器,因此您需要包含 CSS 和 JS 资产。由于您需要许可证,因此未提供这些资产。您可以自由切换编辑器。需要所见即所得的文本区域被分配了 redactor-editor 类。

用法

以下控制台命令可供开发者使用。

# Push all language lines to the database. Existing database values will remain untouched.
$ php artisan squanto:push

# Remove database lines that are no longer present in the language files.
$ php artisan squanto:purge

# Check if your database lines are up to date, and if a push or purge command is advised.
$ php artisan squanto:check

# Rebuild the database cache.
$ php artisan squanto:cache

变更日志

有关最近更改的更多信息,请参阅 变更日志

测试

$ composer test

安全

如果您发现任何与安全相关的问题,请通过电子邮件发送到 dev@thinktomorrow.be,而不是使用问题跟踪器。

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件