AddUsingTemplateCommand
extends AbstractCommand
in package
Language command: add string using template.
Tags
Table of Contents
- $filesToIgnore : array<string|int, string>
- Files to ignore when processing directories
- $languageDir : string
- Language directory
- $normalizer : ExtendedIniNormalizer
- Normalizer for .ini files
- $reader : ExtendedIniReader
- Reader for .ini files
- __construct() : mixed
- Constructor
- addLineToFile() : void
- Add a line to a language file
- configure() : void
- Configure the command.
- createMissingFiles() : void
- Create empty files if they do not already exist.
- execute() : int
- Run the command.
- extractTextDomain() : array<string|int, mixed>
- Extract a text domain and key from a raw language key.
- getLangDir() : object|bool
- Open the language directory as an object using dir(). Return false on failure.
- processDirectory() : void
- Process a language directory.
Properties
$filesToIgnore
Files to ignore when processing directories
protected
array<string|int, string>
$filesToIgnore
= ['aliases.ini', 'native.ini']
$languageDir
Language directory
protected
string
$languageDir
$normalizer
Normalizer for .ini files
protected
ExtendedIniNormalizer
$normalizer
$reader
Reader for .ini files
protected
ExtendedIniReader
$reader
Methods
__construct()
Constructor
public
__construct([ExtendedIniNormalizer $normalizer = null ][, ExtendedIniReader $reader = null ][, string $languageDir = null ][, string|null $name = null ]) : mixed
Parameters
- $normalizer : ExtendedIniNormalizer = null
-
Normalizer for .ini files
- $reader : ExtendedIniReader = null
-
Reader for .ini files
- $languageDir : string = null
-
Base language file directory
- $name : string|null = null
-
The name of the command; passing null means it must be set in configure()
Return values
mixed —addLineToFile()
Add a line to a language file
protected
addLineToFile(string $filename, string $key, string $value) : void
Parameters
- $filename : string
-
File to update
- $key : string
-
Name of language key
- $value : string
-
Value of translation
Return values
void —configure()
Configure the command.
protected
configure() : void
Return values
void —createMissingFiles()
Create empty files if they do not already exist.
protected
createMissingFiles(string $path, array<string|int, mixed> $files) : void
Parameters
- $path : string
-
Directory path
- $files : array<string|int, mixed>
-
Filenames to create in directory
Return values
void —execute()
Run the command.
protected
execute(InputInterface $input, OutputInterface $output) : int
Parameters
- $input : InputInterface
-
Input object
- $output : OutputInterface
-
Output object
Return values
int —0 for success
extractTextDomain()
Extract a text domain and key from a raw language key.
protected
extractTextDomain(string $raw) : array<string|int, mixed>
Parameters
- $raw : string
-
Raw language key
Return values
array<string|int, mixed> —[textdomain, key]
getLangDir()
Open the language directory as an object using dir(). Return false on failure.
protected
getLangDir(OutputInterface $output[, string $domain = 'default' ][, bool $createIfMissing = false ]) : object|bool
Parameters
- $output : OutputInterface
-
Output object
- $domain : string = 'default'
-
Text domain to retrieve.
- $createIfMissing : bool = false
-
Should we create a missing directory?
Return values
object|bool —processDirectory()
Process a language directory.
protected
processDirectory(object $dir, callable $callback[, bool $statusCallback = false ]) : void
Parameters
- $dir : object
-
Directory object from dir() to process
- $callback : callable
-
Function to run on all .ini files in $dir
- $statusCallback : bool = false
-
Callback function to display status messages (omit to suppress messages)