Laravel-Backpack / LangFileManager

A quick interface to edit Laravel language files, for Backpack.
http://backpackforlaravel.com
MIT License
92 stars 42 forks source link

adding translation file like file_name #48

Closed abdelrahmanahmed closed 6 years ago

abdelrahmanahmed commented 6 years ago

I have added file_name in my translation files (with underscore) the problem is in this method : vendor/backpack/langfilemanager/src/app/Services/LangFiles.php

    public function getlangFiles()
    {
        $fileList = [];

        foreach (scandir($this->getLangPath(), SCANDIR_SORT_DESCENDING) as $file) {
            $fileName = str_replace('.php', '', $file);

            if (! in_array($fileName, array_merge(['.', '..'], config('backpack.langfilemanager.language_ignore')))) {
                $fileList[] = [
                    'name' => ucfirst(str_replace('_', ' ', $fileName)),
                    'url' => url(config('backpack.base.route_prefix', 'admin')."/language/texts/{$this->lang}/{$fileName}"),
                    'active' => $fileName == $this->file,
                ];
            }
        }

        // Sort files by name for better readability
        usort($fileList, function ($a, $b) {
            return strnatcmp($a['name'], $b['name']);
        });

        return $fileList;
    }

you remove underscore from the file name , and in the view

<a href="{{ route('language.showTexts', ['lang' => $currentLanguage, 'file' => strtolower($file['name'])]) }}">{{ $file['name'] }}</a> the name will be correct but the file will not located correctly and will not appear the translation file in the view at then , should i make a pull request for this ?

lloy0076 commented 6 years ago

A PR would be most welcome.

tabacitu commented 6 years ago

Merged your PR, thank you @abdelrahmanahmed !