anavel / translation by anavallasuiza

Manage laravel translation files from your admin panel
37
3
9
Package Data
Maintainer Username: anavallasuiza
Maintainer Contact: adrian@anavallasuiza.com (Adrian P. Blunier)
Package Create Date: 2015-12-01
Package Last Update: 2016-06-17
Home Page:
Language: PHP
License: Unknown
Last Refreshed: 2024-12-19 03:16:44
Package Statistics
Total Downloads: 37
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 9
Total Forks: 1
Total Open Issues: 4

Anavel translation Build Status Scrutinizer Code Quality Code Coverage StyleCI

Manage laravel translation files from your admin panel. This package depends on Anavel foundation

Features

  • Easily manage app and vendor translation files.
  • Automatically reorders translations (alphabetically)
  • Easily create new language lines
  • Arrays supported

Installation

Configuration

Publish translation config file with php artisan vendor:publish

Include the files you want to manage within the files array, like this:

    /*
    |--------------------------------------------------------------------------
    | Files to translate
    |--------------------------------------------------------------------------
    |
    */
    'files' => [
        'user'   => [
            'aFileName',
            'anotherFileName'
        ],
        'vendor' => [
            'vendorname' => 'vendorFileName'
        ]
    ],

user is an array of filenames (without extension) located in Laravel's default folder (resources/lang/LOCALE_NAME). vendor is an associative array of filenames (without extension), keyed by vendorname, located in Laravel's default folder (resources/lang/vendor/VENDORNAME/LOCALE_NAME).

This package will read and then write those files, so your app must have write permissions to those folders. You must specify a disc driver for Laravel to use:

config/anavel-translation.php:

    /*
    |--------------------------------------------------------------------------
    | File Disc Driver
    |--------------------------------------------------------------------------
    |
    | Disc driver pointing to resources/lang folder
    |
    */
    'filedriver'  => 'YOUR_DRIVER_NAME',

config/filesystem.php:

    'disks' => [
        [SOME OTHER FILE DRIVERS ],
        'YOUR_DRIVER_NAME' => [
            'driver' => 'local',
            'root'   => base_path('resources/lang'),
        ],
    ]

Versioning

If you use a versioning system (such as git) you should add the language folder to your gitignore. Otherwise, you might get conflicts if different users update the translations.

How it works

Translations reads the files that you specify in the config and displays their content in a form, tabbed by locale. The translation key becomes the input label and the translation itself becomes the input value. Locales are taken from the Anavel foundation config.

To make the translation process easier, Translation shows the same language entries in all locales, even if a key is missing in a given locale. In that case, the displayed text will be taken from the fallback locale (as Laravel does).

When saved, translations are written back to the files. If a file doesn't exist in a locale, a new one is created.