PHP Class Xinax\LaravelGettext\FileSystem

Show file Open project: xinax/laravel-gettext Class Usage Examples

Protected Properties

Property Type Description
$basePath string File system base path All paths will be relative to this
$configuration Xinax\LaravelGettext\Config\Models\Config Package configuration model
$folderName string The folder name in which the language files are stored
$storageContainer string Storage directory name for view compilation
$storagePath string Storage path for file generation

Public Methods

Method Description
__construct ( Config $config, $basePath, $storagePath )
addLocale ( String $localePath, String $locale ) Adds a new locale directory + .po file
checkDirectoryStructure ( boolean | false $checkLocales = false ) : boolean Checks the required directory Optionally checks each local directory, if $checkLocales is true
clearDirectory ( string $path ) : null | boolean Removes the directory contents recursively
compileViews ( array $viewPaths, string $domain ) : boolean Build views in order to parse php files
createPOFile ( string $path, string $locale, string $domain, boolean | true $write = true ) : integer | string Creates a configured .po file on $path If PHP are not able to create the file the content will be returned instead
generateLocales ( ) : array Creates the localization directories and files by domain
getBasePath ( ) : string Get the filesystem base path
getConfiguration ( ) : Config Gets the package configuration model.
getDomainPath ( null $append = null ) : string Constructs and returns the full path to the translation files
getFolderName ( ) : string Get the folder name
getRelativePath ( string $from, string $to ) : string Return the relative path from a file or directory to anothe
getStorageForDomain ( $domain ) : String Get the full path for domain storage directory
getStoragePath ( ) : string Get the storage path
makePOFilePath ( $locale, $domain ) : string Returns the full path for a .po file from its domain and locale
setBasePath ( $basePath ) Set the filesystem base path
setConfiguration ( Config $configuration ) Set the package configuration model
setFolderName ( $folderName ) Set the folder name
setStoragePath ( $storagePath ) Set the storage path
updateLocale ( $localePath, $locale, $domain ) : boolean Update the .po file headers by domain (mainly source-file paths)

Protected Methods

Method Description
createDirectory ( $path ) Validate if the directory can be created

Method Details

__construct() public method

public __construct ( Config $config, $basePath, $storagePath )
$config Xinax\LaravelGettext\Config\Models\Config
$basePath
$storagePath

addLocale() public method

Adds a new locale directory + .po file
public addLocale ( String $localePath, String $locale )
$localePath String
$locale String

checkDirectoryStructure() public method

Checks the required directory Optionally checks each local directory, if $checkLocales is true
public checkDirectoryStructure ( boolean | false $checkLocales = false ) : boolean
$checkLocales boolean | false
return boolean

clearDirectory() public static method

Removes the directory contents recursively
public static clearDirectory ( string $path ) : null | boolean
$path string
return null | boolean

compileViews() public method

Build views in order to parse php files
public compileViews ( array $viewPaths, string $domain ) : boolean
$viewPaths array
$domain string
return boolean

createDirectory() protected method

Validate if the directory can be created
protected createDirectory ( $path )
$path

createPOFile() public method

Creates a configured .po file on $path If PHP are not able to create the file the content will be returned instead
public createPOFile ( string $path, string $locale, string $domain, boolean | true $write = true ) : integer | string
$path string
$locale string
$domain string
$write boolean | true
return integer | string

generateLocales() public method

Creates the localization directories and files by domain
public generateLocales ( ) : array
return array

getBasePath() public method

Get the filesystem base path
public getBasePath ( ) : string
return string

getConfiguration() public method

Gets the package configuration model.
public getConfiguration ( ) : Config
return Xinax\LaravelGettext\Config\Models\Config

getDomainPath() public method

Constructs and returns the full path to the translation files
public getDomainPath ( null $append = null ) : string
$append null
return string

getFolderName() public method

Get the folder name
public getFolderName ( ) : string
return string

getRelativePath() public method

Return the relative path from a file or directory to anothe
Author: Laurent Goussard
public getRelativePath ( string $from, string $to ) : string
$from string
$to string
return string

getStorageForDomain() public method

Get the full path for domain storage directory
public getStorageForDomain ( $domain ) : String
$domain
return String

getStoragePath() public method

Get the storage path
public getStoragePath ( ) : string
return string

makePOFilePath() public method

Returns the full path for a .po file from its domain and locale
public makePOFilePath ( $locale, $domain ) : string
$locale
$domain
return string

setBasePath() public method

Set the filesystem base path
public setBasePath ( $basePath )
$basePath

setConfiguration() public method

Set the package configuration model
public setConfiguration ( Config $configuration )
$configuration Xinax\LaravelGettext\Config\Models\Config

setFolderName() public method

Set the folder name
public setFolderName ( $folderName )
$folderName

setStoragePath() public method

Set the storage path
public setStoragePath ( $storagePath )
$storagePath

updateLocale() public method

Update the .po file headers by domain (mainly source-file paths)
public updateLocale ( $localePath, $locale, $domain ) : boolean
$localePath
$locale
$domain
return boolean

Property Details

$basePath protected property

File system base path All paths will be relative to this
protected string $basePath
return string

$configuration protected property

Package configuration model
protected Config,Xinax\LaravelGettext\Config\Models $configuration
return Xinax\LaravelGettext\Config\Models\Config

$folderName protected property

The folder name in which the language files are stored
protected string $folderName
return string

$storageContainer protected property

Storage directory name for view compilation
protected string $storageContainer
return string

$storagePath protected property

Storage path for file generation
protected string $storagePath
return string