PHP Класс Themsaid\Langman\Manager

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( Illuminate\Filesystem\Filesystem $disk, string $path, array $syncPaths ) Manager constructor.
collectFromFiles ( ) : array Collect all translation keys from views files.
createFile ( $fileName ) : void Create a file for all languages if does not exist already.
files ( ) : array Array of language files grouped by file name.
fillKeys ( string $fileName, array $keys ) : void Fills translation lines for given keys in different languages.
getAllViewFilesWithTranslations ( ) : array Get found translation lines found per file.
getFileContent ( string $filePath, boolean $createIfNotExists = false ) : array Get the content in the given file path.
getKeysExistingInALanguageButNotTheOther ( $values ) : array Extract keys that exists in a language but not the other.
languages ( ) : array Array of supported languages.
removeKey ( string $fileName, string $key ) : void Remove a key from all language files.
setPathToVendorPackage ( string $packageName ) : void Sets the path to a vendor package translation files.
writeFile ( string $filePath, array $translations ) : void Write a language file from array.

Приватные методы

Метод Описание
neglectVendorFiles ( $filesByFile ) : array Nelgect all vendor files.
stringLineMaker ( $array, $prepend = '' ) : string Write the lines of the inner array of the language file.

Описание методов

__construct() публичный Метод

Manager constructor.
public __construct ( Illuminate\Filesystem\Filesystem $disk, string $path, array $syncPaths )
$disk Illuminate\Filesystem\Filesystem
$path string
$syncPaths array

collectFromFiles() публичный Метод

e.g. ['users' => ['city', 'name', 'phone']]
public collectFromFiles ( ) : array
Результат array

createFile() публичный Метод

Create a file for all languages if does not exist already.
public createFile ( $fileName ) : void
$fileName
Результат void

files() публичный Метод

ex: ['user' => ['en' => 'user.php', 'nl' => 'user.php']]
public files ( ) : array
Результат array

fillKeys() публичный Метод

ex. for $keys = ['name' => ['en' => 'name', 'nl' => 'naam']
public fillKeys ( string $fileName, array $keys ) : void
$fileName string
$keys array
Результат void

getAllViewFilesWithTranslations() публичный Метод

e.g. ['users.blade.php' => ['users.name'], 'users/index.blade.php' => ['users.phone', 'users.city']]
public getAllViewFilesWithTranslations ( ) : array
Результат array

getFileContent() публичный Метод

Get the content in the given file path.
public getFileContent ( string $filePath, boolean $createIfNotExists = false ) : array
$filePath string
$createIfNotExists boolean
Результат array

getKeysExistingInALanguageButNotTheOther() публичный Метод

Given a dot array of all keys in the format 'file.language.key', this method searches for keys that exist in one language but not the other and outputs an array consists of those keys.
public getKeysExistingInALanguageButNotTheOther ( $values ) : array
$values
Результат array

languages() публичный Метод

ex: ['en', 'sp']
public languages ( ) : array
Результат array

removeKey() публичный Метод

Remove a key from all language files.
public removeKey ( string $fileName, string $key ) : void
$fileName string
$key string
Результат void

setPathToVendorPackage() публичный Метод

Sets the path to a vendor package translation files.
public setPathToVendorPackage ( string $packageName ) : void
$packageName string
Результат void

writeFile() публичный Метод

Write a language file from array.
public writeFile ( string $filePath, array $translations ) : void
$filePath string
$translations array
Результат void