定制 blok/i18n-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

blok/i18n-manager

Composer 安装命令:

composer require blok/i18n-manager

包简介

A i18n manager

README 文档

README

Build Status styleci Scrutinizer Code Quality SensioLabsInsight Coverage Status

Packagist Packagist Packagist

Package description:

Import a Google spreadsheet into your Laravel Application

Installation

Install via composer

composer require blok/i18n-manager

Register Service Provider

Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.

Add service provider to config/app.php in providers section

Blok\I18nManager\ServiceProvider::class,

Register Facade

Register package facade in config/app.php in aliases section

Blok\I18nManager\Facades\I18nManager::class,

Publish Configuration File

php artisan vendor:publish --provider="Blok\I18nManager\ServiceProvider" --tag="config"

Usage

Your google spreadsheet have to have this structure :

REFENFRNLcreated_atupdated_at

Then you will need to publish the spreadsheet as a CSV output by clicking on File > Publish to the web

https://www.evernote.com/l/AHdbGjzj0jFLNKuZTvxsAVGK_6dnpDKCvGg

After that you need to add the url of the csv file into config/i18n-manager.php config files.

Then depending of your business logic, you can call the :

  • Blok\I18nManager\Jobs\TranslationsExporterJob : to export your existing laravel translations (/!\ will simply output an html table that you will need to copy-paste into your Google Spreadsheets)
  • Blok\I18nManager\Jobs\TranslationsImporterJob : to import translations back into your Laravel application

You can also call the import/export like that :


app('i18n-manager')->export();

app('i18n-manager')->import();

Exemples of integration

For exemple in an AdminController, if in a protected route user add labels_export=1 or labels_import=1 => it will export or import labels.

class AdminController{
    public function index(){
      if(request()->has('labels_export')){
          app('i18n-manager')->export();
      }

      if(request()->has('labels_import')){
          app('i18n-manager')->import();
      }
    }
}

How to blacklist some non exported labels/references ?

Sometimes you don't want to update/sync some labels into google spreadsheets. To blacklist some references, you can add it into the config/i18n-manager.php and adding your own regex.

How to allow the creation of new ref by the customer ?

Warning!!! : This is something that might used only in a testing environment as it might cause unexpected behavior on production if the user override by mistake an other ref !!

After exporting the config file in the config/i18n-manager.php set :

<?php

return [
    //...
    'allow_new_ref' => true,
    //...
];

You can also create or override on the fly the config right after the import for instance :

class AdminController{
    public function index(){
      if(request()->has('labels_export')){
          app('i18n-manager')->export();
      }

      if(request()->has('add_new_ref')){
        config(['i18n-manager' => true]);
      }

      if(request()->has('labels_import')){
          app('i18n-manager')->import();
      }
    }
}

Warning

This package doesn't give a way to automatically create a spreadsheet + update the spreadsheet as it requires more cumbersome autorization from Google API.

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固