Coder Social home page Coder Social logo

translation's Introduction

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.

translation's People

Contributors

ablunier avatar cmoralesweb avatar

Stargazers

Swapnil Tripathi avatar Berto Yáñez avatar Carlos González Goce avatar

Watchers

James Cloos avatar Rubén Prol avatar Xabier avatar  avatar  avatar  avatar María Yáñez avatar  avatar Agos Reigosa avatar

Forkers

ablunier

translation's Issues

Sobre os nomes deste sistema

Que nomes teñen as pezas deste framework? Como chegastes a eles?

(explicádenos como chegastes ata eles para que o entendamos mellor, please... se cadra ocórresenos algo tan wai, pero máis breve), 👯 / @cmoralesweb @ablunier

Arrays get overwritten

When adding elements, using the dot sintax (arraykey.key), if a previous array exists, it gets overwritten.

Support to add new language lines

Including arrays (for cases such as validation.php):


    /*
    |--------------------------------------------------------------------------
    | Custom Validation Attributes
    |--------------------------------------------------------------------------
    |
    | The following language lines are used to swap attribute place-holders
    | with something more reader friendly such as E-Mail Address instead
    | of "email". This simply helps us make messages a little cleaner.
    |
    */

    'attributes' => [],

Multiple files for a vendor

When configuring files to translate for vendors:

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

can't configure multiple 'vendorFileName'. It should accept multiple files (as array) for a vendor name.

Locale forms should be independent

Currently, all locales share the same form (and submit button). That means that missing entries get saved with the fallback locale if not edited.

Forms should be independent per tab, so only the visible locale gets submitted.

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.