GithubHelp home page GithubHelp logo

astaphobia / translation-sheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prinzio/translation-sheet

0.0 2.0 0.0 348 KB

Translating Laravel languages files using a Google Spreadsheet.

License: MIT License

PHP 100.00%

translation-sheet's Introduction

related

Laravel Translation Sheet

Translating Laravel languages files using a Google Spreadsheet.

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score

Laravel Translation Sheet

Contents

Installation

  • Install package

    $ composer require nikaia/translation-sheet
  • Add service provider to your 'config/app.php'

    Nikaia\TranslationSheet\TranslationSheetServiceProvider::class,
  • Configuration can be done via environments variables, but if you prefer you can override the configuration by publishing the package config file using :

    $ php artisan vendor:publish --provider="Nikaia\TranslationSheet\TranslationSheetServiceProvider"

Requirements

Laravel 5.1 | 5.2 | 5.3 | 5.4

Configuration

Google Api

  • head to https://console.developers.google.com/
  • create a new project
  • Make sure to activate Sheet Api for the project
    • Navigate to "Library"
    • Search "Google Sheets API" > Click on "Google Sheets API"
    • Click "Enable"
  • Create a Service Account and credentials
    • Navigate to "Credentials"
    • Click "Create credentials"
    • choose "Service Account key"
    • Choose A "New Service Account" in the "Service account" select
    • Choose a name. (ie. This is the name that will show up in the Spreadsheet history operations), "Editor" as role and "JSON" for the key type.
    • Save the credentials to 'resources/google/service-account.json' folder. (You can choose another name/folder if you want in your application folder)
    • Make sure to write down the service account email, you will need it later for the package configuration.

Spreadsheet

Required configuration

In your .env file or in your published config file (config/translation_sheet.php)

# The service account email   
TS_SERVICE_ACCOUNT_EMAIL=***@***.iam.gserviceaccount.com

# The path to the downloaded service account credentials file
TS_SERVICE_ACCOUNT_CREDENTIALS_FILE=resources/google/service-account.json

# The ID of the spreadsheet that we will be using for translation
TS_SPREADSHEET_ID=xxxx

# The locales of the application (separated by comma) 
TS_LOCALES=fr,en,es

Usage

1/ Setup the spreadsheet

This need to be done only once.

$ php artisan translation_sheet:setup

2/ Prepare the sheet

To avoid some conflicts, we will first run this command to rewrite the locale languages files.

$ php artisan translation_sheet:prepare

3/ Publish translation to sheet

$ php artisan translation_sheet:push

4/ Share the spreadsheet with clients or project managers for translations.

5/ Once done, You can lock the translations on the spreadsheet (to avoid conflicts)

$ php artisan translation_sheet:lock

6/ Pull the translations

This will pull the translations from the spreadsheet, and write it the language files in your applications. You can use git diff here to make sure eveything is ok (Conflicts, errors etc ...)

$ php artisan translation_sheet:pull

6/ Unlock the translations on the spreadsheet

$ php artisan translation_sheet:unlock

Open the spreadsheet in the browser

$ php artisan translation_sheet:open

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

N.B : You need a valid configuration service-account.json file to run tests.

Travis

To test your fork using travis, you need the a valid service-account.json. The file is ignored in the repository to avoid exposing credentials. You need to encode your credentials file `tests/fixtures/service-account.json using travis utilities.

# Save credential file to tests/fixtures/service-account.json
$ cd tests/fixtures
$ travis encrypt-file service-account.json

Commit the .enc result file.

PS. Travis will decrypt the file just before running the tests. See the travis.yml file.

before_install:
    - openssl aes-256-cbc -K $encrypted_5affb966e7f5_key -iv $encrypted_5affb966e7f5_iv -in tests/fixtures/service-account.json.enc -out tests/fixtures/service-account.json -d

Security

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

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

translation-sheet's People

Contributors

nbourguig avatar tr-github avatar

Watchers

James Cloos avatar Ketut Ariasa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.