承接 sawirricardo/laravel-translation-loader 相关项目开发

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

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

sawirricardo/laravel-translation-loader

最新稳定版本:0.0.3

Composer 安装命令:

composer require sawirricardo/laravel-translation-loader

包简介

Store your translations in the database or other sources, using the modern packages

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

In a vanilla Laravel or Lumen installation you can use language files to localize your app. This package will enable the translations to be stored in the database. You can still use all the features of the trans function you know and love.

trans('messages.welcome', ['name' => 'dayle']);

You can even mix using language files and the database. If a translation is present in both a file and the database, the database version will be returned.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require sawirricardo/laravel-translation-loader

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-translation-loader-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-translation-loader-config"

This is the contents of the published config file:

'translation_loaders' => [
    \Sawirricardo\LaravelTranslationLoader\TranslationLoaders\Db::class,
],

'model' => \Sawirricardo\LaravelTranslationLoader\Models\Translation::class,

'translation_manager' => \Sawirricardo\LaravelTranslationLoader\TranslationLoaderManager::class,

'locals' => [
    'en' => 'English',
    'ar' => 'Arabic',
    'pt_BR' => 'Português (Brasil)',
    'my' => 'Burmese',
    'id' => 'Bahasa Indonesia',
],

'paths' => [
    app_path(),
    resource_path('views'),
    base_path('vendor'),
],

'excluded_paths' => [
    //
],

Usage

use Sawirricardo\LaravelTranslationLoader\Models\Translation;

Translation::create([
   'group' => 'validation',
   'key' => 'required',
   'text' => ['en' => 'This is a required field', 'nl' => 'Dit is een verplicht veld'],
]);

You can fetch the translation with Laravel's default trans function:

trans('validation.required'); // returns 'This is a required field'

app()->setLocale('nl');

trans('validation.required'); // returns 'Dit is een verplicht veld'

Creating your own translation providers

This package ships with a translation provider than can fetch translations from the database. If you're storing your translations in a yaml-file, a csv-file, or ... you can easily extend this package by creating your own translation provider.

A translation provider can be any class that implements the Sawirricardo\LaravelTranslationLoader\TranslationLoaders\TranslationLoader-interface. It contains only one method:

namespace Sawirricardo\LaravelTranslationLoader\TranslationLoaders;

interface TranslationLoader { public function loadTranslations($locale, $group); } Translation providers can be registered in the translation_loaders key of the config file.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固