PHP Class Themsaid\Langman\Manager

Afficher le fichier Open project: themsaid/laravel-langman Class Usage Examples

Méthodes publiques

Méthode Description
__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.

Private Methods

Méthode Description
neglectVendorFiles ( $filesByFile ) : array Nelgect all vendor files.
stringLineMaker ( $array, $prepend = '' ) : string Write the lines of the inner array of the language file.

Method Details

__construct() public méthode

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

collectFromFiles() public méthode

e.g. ['users' => ['city', 'name', 'phone']]
public collectFromFiles ( ) : array
Résultat array

createFile() public méthode

Create a file for all languages if does not exist already.
public createFile ( $fileName ) : void
$fileName
Résultat void

files() public méthode

ex: ['user' => ['en' => 'user.php', 'nl' => 'user.php']]
public files ( ) : array
Résultat array

fillKeys() public méthode

ex. for $keys = ['name' => ['en' => 'name', 'nl' => 'naam']
public fillKeys ( string $fileName, array $keys ) : void
$fileName string
$keys array
Résultat void

getAllViewFilesWithTranslations() public méthode

e.g. ['users.blade.php' => ['users.name'], 'users/index.blade.php' => ['users.phone', 'users.city']]

getFileContent() public méthode

Get the content in the given file path.
public getFileContent ( string $filePath, boolean $createIfNotExists = false ) : array
$filePath string
$createIfNotExists boolean
Résultat array

getKeysExistingInALanguageButNotTheOther() public méthode

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
Résultat array

languages() public méthode

ex: ['en', 'sp']
public languages ( ) : array
Résultat array

removeKey() public méthode

Remove a key from all language files.
public removeKey ( string $fileName, string $key ) : void
$fileName string
$key string
Résultat void

setPathToVendorPackage() public méthode

Sets the path to a vendor package translation files.
public setPathToVendorPackage ( string $packageName ) : void
$packageName string
Résultat void

writeFile() public méthode

Write a language file from array.
public writeFile ( string $filePath, array $translations ) : void
$filePath string
$translations array
Résultat void