VuFind API Documentation

ImportLokaliseCommand extends AbstractCommand
in package

Language command: ingest and normalise language files exported from Lokalise.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

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
collectSourceFiles()  : array<string|int, string>
Recurse through a directory collecting all .ini files.
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.
formatLokaliseLine()  : string
Format a single line from a Lokalise language file so it is ready for further processing by the language file normalizer.
getLangDir()  : object|bool
Open the language directory as an object using dir(). Return false on failure.
importStrings()  : void
Add new strings from $sourceFile to $targetFile.
matchTargetFiles()  : array<string|int, string>
Given an array of files in $sourceDir, return an array of equivalent matching filenames in $targetDir.
processDirectory()  : void
Process a language directory.
writeToDisk()  : void
Write content to disk.

Properties

$filesToIgnore

Files to ignore when processing directories

protected array<string|int, string> $filesToIgnore = ['aliases.ini', 'native.ini']

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

collectSourceFiles()

Recurse through a directory collecting all .ini files.

protected collectSourceFiles(string $dir) : array<string|int, string>
Parameters
$dir : string

Directory to explore

Return values
array<string|int, string>

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]

formatLokaliseLine()

Format a single line from a Lokalise language file so it is ready for further processing by the language file normalizer.

protected formatLokaliseLine(string $line) : string
Parameters
$line : string

Line to format

Return values
string

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

importStrings()

Add new strings from $sourceFile to $targetFile.

protected importStrings(string $sourceFile, string $targetFile) : void
Parameters
$sourceFile : string

New file from Lokalise

$targetFile : string

Existing file in VuFind

Return values
void

matchTargetFiles()

Given an array of files in $sourceDir, return an array of equivalent matching filenames in $targetDir.

protected matchTargetFiles(string $sourceDir, string $targetDir, array<string|int, string> $sourceFiles) : array<string|int, string>
Parameters
$sourceDir : string

Source directory

$targetDir : string

Target directory

$sourceFiles : array<string|int, string>

Source files

Return values
array<string|int, string>

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)

Return values
void

writeToDisk()

Write content to disk.

protected writeToDisk(string $file, string $text) : void
Parameters
$file : string

Filename

$text : string

Text to write

Return values
void

Search results