i18nTextCollector
class i18nTextCollector
SilverStripe-variant of the "gettext" tool: Parses the string content of all PHP-files and SilverStripe templates for ocurrences of the _t() translation method. Also uses the {@link i18nEntityProvider} interface to get dynamically defined entities by executing the {@link provideI18nEntities()} method on all implementors of this interface.
Collects all found entities (and their natural language text for the default locale) into language-files for each module in an array notation. Creates or overwrites these files, e.g. framework/lang/en.yml.
The collector needs to be run whenever you make new translatable entities available. Please don't alter the arrays in language tables manually.
Usage through URL: http://localhost/dev/tasks/i18nTextCollectorTask Usage through URL (module-specific): http://localhost/dev/tasks/i18nTextCollectorTask/?module=mymodule Usage on CLI: sake dev/tasks/i18nTextCollectorTask Usage on CLI (module-specific): sake dev/tasks/i18nTextCollectorTask module=mymodule
Traits
Properties
string | $basePath | The directory base on which the collector should act. | |
string | $baseSavePath | Save path |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
No description
This is the main method to build the master string tables with the original strings. It will search for existent modules that use the i18n feature, parse the _t() calls and write the resultant files in the lang folder of each module.
Extract all strings from modules and return these grouped by module name
Extracts translatables from .php files.
Extracts translatables from .ss templates (Self referencing)
Allows classes which implement i18nEntityProvider to provide additional translation strings.
No description
No description
No description
No description
Details
in Injectable at line 26
static Injectable
create(array $args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
in Injectable at line 43
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
at line 101
__construct($locale = null)
at line 117
$this
setWriter(Writer $writer)
Assign a writer
at line 128
Writer
getWriter()
Gets the currently assigned writer, or the default if none is specified.
at line 138
Reader
getReader()
Get reader
at line 149
$this
setReader(Reader $reader)
Set reader
at line 170
run(array $restrictToModules = null, bool $mergeWithExisting = false)
This is the main method to build the master string tables with the original strings. It will search for existent modules that use the i18n feature, parse the _t() calls and write the resultant files in the lang folder of each module.
at line 198
array
collect(array $restrictToModules = array(), bool $mergeWithExisting = false)
Extract all strings from modules and return these grouped by module name
at line 454
$this
write(Module $module, array $entities)
Write entities to a module
at line 548
array
collectFromCode(string $content, string $fileName, Module $module)
Extracts translatables from .php files.
Note: Translations without default values are omitted.
at line 774
array
collectFromTemplate(string $content, string $fileName, Module $module, array $parsedFiles = array())
Extracts translatables from .ss templates (Self referencing)
at line 811
array
collectFromEntityProviders(string $filePath, Module $module = null)
Allows classes which implement i18nEntityProvider to provide additional translation strings.
Not all classes can be instanciated without mandatory arguments, so entity collection doesn't work for all SilverStripe classes currently