Language files manager in your artisan console.

Overview

Laravel Langman

Langman is a language files manager in your artisan console, it helps you search, update, add, and remove translation lines with ease. Taking care of a multilingual interface is not a headache anymore.

Laravel Langman
Build Status StyleCI Latest Stable Version Total Downloads License

Installation

Begin by installing the package through Composer. Run the following command in your terminal:

$ composer require themsaid/laravel-langman

Once done, add the following line in your providers array of config/app.php:

Themsaid\Langman\LangmanServiceProvider::class

This package has a single configuration option that points to the resources/lang directory, if only you need to change the path then publish the config file:

php artisan vendor:publish --provider="Themsaid\Langman\LangmanServiceProvider"

Usage

Showing lines of a translation file

php artisan langman:show users

You get:

+---------+---------------+-------------+
| key     | en            | nl          |
+---------+---------------+-------------+
| name    | name          | naam        |
| job     | job           | baan        |
+---------+---------------+-------------+

php artisan langman:show users.name

Brings only the translation of the name key in all languages.


php artisan langman:show users.name.first

Brings the translation of a nested key.


php artisan langman:show package::users.name

Brings the translation of a vendor package language file.


php artisan langman:show users --lang=en,it

Brings the translation of only the "en" and "it" languages.


php artisan langman:show users.nam -c

Brings only the translation lines with keys matching the given key via close match, so searching for nam brings values for keys like (name, username, branch_name_required, etc...).

In the table returned by this command, if a translation is missing it'll be marked in red.

Finding a translation line

php artisan langman:find 'log in first'

You get a table of language lines where any of the values matches the given phrase by close match.

Searching view files for missing translations

php artisan langman:sync

This command will look into all files in resources/views and app and find all translation keys that are not covered in your translation files, after that it appends those keys to the files with a value equal to an empty string.

Filling missing translations

php artisan langman:missing

It'll collect all the keys that are missing in any of the languages or has values equals to an empty string, prompt asking you to give a translation for each, and finally save the given values to the files.

Translating a key

php artisan langman:trans users.name
php artisan langman:trans users.name.first
php artisan langman:trans users.name --lang=en
php artisan langman:trans package::users.name

Using this command you may set a language key (plain or nested) for a given group, you may also specify which language you wish to set leaving the other languages as is.

This command will add a new key if not existing, and updates the key if it is already there.

Removing a key

php artisan langman:remove users.name
php artisan langman:remove package::users.name

It'll remove that key from all language files.

Renaming a key

php artisan langman:rename users.name full_name

This will rename users.name to be users.full_name, the console will output a list of files where the key used to exist.

Notes

langman:sync, langman:missing, langman:trans, and langman:remove will update your language files by writing them completely, meaning that any comments or special styling will be removed, so I recommend you backup your files.

Web interface

If you want a web interface to manage your language files instead, I recommend Laravel 5 Translation Manager by Barry vd. Heuvel.

Comments
  • Undefined offset: 1

    Undefined offset: 1

    $ php artisan langman:missing
    Looking for missing translations...
    
      [ErrorException]
      Undefined offset: 1
    

    No idea why that happens. I got some vendor files and maybe some files are created in one language and not in the others.

    opened by vpratfr 18
  • Sync is ignoring anything outside views

    Sync is ignoring anything outside views

    There are lots of places where we have messages: controllers, validation, events, etc. All of them are not taken into account, just the views.

    This would be fair to incorporate those classes into the sync process.

    enhancement 
    opened by vpratfr 10
  • Sync views with app files

    Sync views with app files

    as mentioned in #21 , sync just working with views paths , in this PR the sync working with all views and app subdirectories , i don't know if the global app_path is fine or i have to specify some directories only but i think we need any lang method used in app or view path

    opened by ahmedash95 6
  • Lower PHP requirement

    Lower PHP requirement

    You currently require PHP7, which is way above the requirement set by Laravel itself. Could you update the composer file so that we can still install it?

    opened by vpratfr 5
  • Ignore

    Ignore "arrays" when sync

    Hi,

    I have this lang file e.g

    // file lang/users.php
    return [
       'tips' => [
          'one' => 'First tip',
          'two' => 'Second tip',
          // etc.
       ]
    ];
    

    And in a controller or a file inside app directory:

    // lang('users.tips') is an array
    foreach (lang('users.tips') as $tip) {
       // do something with the texts
    }
    

    So the problem is that when I use "langman:sync" command, it writes an empty array in tips.

    // file lang/users.php
    return [
       'tips' => ''
    ];
    

    Is this a bug or an expected behauvior?

    Anyway, congrats for the package, it rocks.

    opened by Luddinus 4
  • specify the languages to display

    specify the languages to display

    some improvements as mentioned in #19 . i made some additional on langman:show command , this PR will allow users to specify the languages that they want to display like

    php artisan langman:show auth --lang=en
    

    for multiple specifications

    php artisan langman:show auth --lang=en,ar
    
    opened by ahmedash95 4
  • specify the languages to display

    specify the languages to display

    some improvements as mentioned in #19 . i made some additional on langman:show command , this PR will allow users to specify the languages that they want to display like

    php artisan langman:show auth --lang=en
    

    for multiple specifications

    php artisan langman:show auth --lang=en,ar
    
    opened by ahmedash95 4
  • php artisan langman:trans vendor error

    php artisan langman:trans vendor error

    How to create the issue:

    1. Create a vendor directory in lang
    php artisan langman:trans nav.new_item
    > Create item
    

    Error:

    Undefined index: vendor
    

    Laravel Version: 5.2

    bug 
    opened by dragonfire1119 4
  • php artisan langman:trans addslashes error

    php artisan langman:trans addslashes error

    How to create the issue:

    php artisan langman:trans nav.new_item
    > Create new item
    

    Error:

    addslashes() expects parameter 1 to be string, array given
    

    Laravel Version: 5.2

    bug 
    opened by dragonfire1119 4
  • Sub-directories translations

    Sub-directories translations

    3rd party packages sometimes allow to publish translation files.

    Those file are usually located inside a subfolder of lang. For instance:

    lang
      |_ en
      |_ fr
      |_ es
      |_ vendor
        |_ package1
        | |_ en
        | |_ fr
        | |_ es
        |_ package2
          |_ en
          |_ es
    
    • Is that supported by your tool?
    • Will package1/package2 get updated too?
    • Will fr be created in package2 folder?
    enhancement 
    opened by vpratfr 4
  • Sync not matching some methods

    Sync not matching some methods

    Sync is ignoring @lang and @choice if they are used just after an HTML tag. For example: <p>@lang('language.line')</p> The problem is that the regex is ignoring them because the first part: [^\w|>] Is that the expected behavior? I have been playing with the regex in https://regex101.com/r/jS5fX0/2 but I'm not sure how to solve this in the right way.

    opened by gregoriohc 3
  • Fix Unparenthesized ternary inside ternary

    Fix Unparenthesized ternary inside ternary

    Fixing ErrorException : Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

    On PHP >= 7.4 this was generating an Exception on my composer install.

    Thanks in advance!

    opened by rcarvs 0
  • Fix: Deprecated Unparenthesized a ? b : c ? d : e`

    Fix: Deprecated Unparenthesized a ? b : c ? d : e`

    I found the issue when executing composer install

    @php artisan package:discover

    ErrorException : Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

    at A:_WebDev_Projects\aymen-requests\laravel_application\vendor\themsaid\laravel-langman\src\Commands\FindCommand.php:113 109| $original = []; 110| 111| foreach ($allLanguages as $languageKey) { 112| $original[$languageKey] =

    113| isset($values[$languageKey]) 114| ? $values[$languageKey] 115| : isset($filesContent[$fileName][$languageKey][$key]) ? $filesContent[$fileName][$languageKey][$key] : ''; 116| } 117|

    Exception trace:

    1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)", "A:_WebDev_Projects\aymen-requests\laravel_application\vendor\themsaid\laravel-langman\src\Commands\FindCommand.php", ["A:_WebDev_Projects\aymen-requests\laravel_application\vendor\composer/../themsaid/laravel-langman/src/Commands/FindCommand.php"]) A:_WebDev_Projects\aymen-requests\laravel_application\vendor\composer\ClassLoader.php:444

    2 include() A:_WebDev_Projects\aymen-requests\laravel_application\vendor\composer\ClassLoader.php:444

    Please use the argument -v to see more details. Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

    And it solved as this stackoverflow answer:

    https://stackoverflow.com/questions/61432488/php-error-unparenthesized-a-b-c-d-e-is-deprecated-use-either-a

    opened by muath-ye 3
  • Langman not compitable with laravel 8,

    Langman not compitable with laravel 8,

    • Laravel Version: 8.12
    • PHP Version: 7.4
    • Database Driver & Version:

    I upgrade my app from lara 5.8 to 8 just I couldn't update langman package

    there is any solution or ignore it ???

    opened by ghostofjava 5
  • Issue Fixed  Unparenthesized deprecated

    Issue Fixed Unparenthesized deprecated

    Following Issue is Fixed!

    ErrorException : Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

    Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)", "I:
    xampp\htdocs\gigxlife-web\vendor\themsaid\laravel-langman\src\Commands\FindCommand.php", ["I:\xampp\htdocs\my_project\vendor\composer/../themsaid/laravel-langman/src/Commands/FindCom mand.php"])

    opened by abdulrehman25 0
Releases(v1.3.5)
Owner
Mohamed Said
Web developer at Laravel
Mohamed Said
[virion] Language management library for automatic translation

libtranslator :: library for automatic translation ✔️ Multilingual support for plugin messages ✔️ Translation language is set according to the player

PocketMine-MP projects of PresentKim 5 Jul 29, 2022
A morphological solution for Russian and English language written completely in PHP.

Morphos A morphological solution for Russian and English language written completely in PHP. Tests & Quality: Features [✓] Inflection of Personal name

Sergey 723 Jan 4, 2023
Geographer is a PHP library that knows how any country, state or city is called in any language

Geographer Geographer is a PHP library that knows how any country, state or city is called in any language. Documentation on the official website Incl

Menara Solutions 757 Nov 24, 2022
Official PHP library for the DeepL language translation API.

deepl-php Official PHP client library for the DeepL API. The DeepL API is a language translation API that allows other computer programs to send texts

DeepL 78 Dec 23, 2022
Translation (i18n) Manager as a virion

TL Translation (i18n) Manager as a virion Translation use hook-like $t = $tl->useTranslation($player->getLocale()); $player->sendMessage($t("message-k

RedMC Network 3 Oct 28, 2022
A GUI for managing JSON translation files in your laravel projects.

Laravel Language Manager Langman is a GUI for managing your JSON language files in a Laravel project. Installation Begin by installing the package thr

Mohamed Said 515 Nov 30, 2022
Manage Laravel translation files

Laravel 5 Translation Manager For Laravel 4, please use the 0.1 branch! This is a package to manage Laravel translation files. It does not replace the

Barry vd. Heuvel 1.5k Jan 4, 2023
A Gui To Manage Laravel Translation Files

Lingo A file based translation manager, which unlike other Lang managers don't need a database connection to handle the translation. Installation comp

Muah 97 Dec 5, 2022
Brings localization feature to tightenco/jigsaw using JSON files

Jigsaw localization Brings localization feature to tightenco/jigsaw using JSON files. Get started Setup Bring jigsaw-localization to your Jigsaw proje

Elaborate Code 6 Nov 1, 2022
Automatically translate and review your content via Lokalise

This extension will work as a bridge between Pimcore and Lokalise for the purpose of automating the whole translation workflow. Thus eliminating most of the manual steps in the task along with availing quality translation-review service from Lokalise.

Pravin chaudhary 6 Jan 10, 2022
The Translation component provides tools to internationalize your application.

Translation Component The Translation component provides tools to internationalize your application. Getting Started $ composer require symfony/transl

Symfony 6.4k Jan 6, 2023
Generates a vue-i18n compatible include file from your Laravel translations

This is fork of martinlindhe/laravel-vue-i18n-generator to give Laravel 8+ support for this excellent package.

Alefe Souza 1 Nov 11, 2021
Filament Translations - Manage your translation with DB and cache

Filament Translations Manage your translation with DB and cache, you can scan your languages tags like trans(), __(), and get the string inside and tr

Fady Mondy 32 Nov 28, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 149 Dec 29, 2022
📝 Artisan Menu - Use Artisan via an elegant console GUI

?? Artisan Menu Use Artisan via an elegant console GUI Features Run built-in and custom Artisan commands from a console GUI Prompts to enter required

Jordan Hall 148 Nov 29, 2022
Dispatcher is a Laravel artisan command scheduling tool used to schedule artisan commands within your project so you don't need to touch your crontab when deploying.

Dispatcher Dispatcher allows you to schedule your artisan commands within your Laravel project, eliminating the need to touch the crontab when deployi

Indatus 1.1k Jan 5, 2023