mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
a3c406e4d2
This is a necessity for any further 3.1 pushes of master files to getlocalization. Because we'd otherwise remove existing master strings for CTF etc, which means we can no longer backport new translations to 3.0 (and there's no way for users to contribute translations to 3.0 via getlocalization). It's still a very monolithic class, but at least I've refactored it to return all collected strings without writing it to files (for easier testing).
44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* @package framework
|
|
* @subpackage tasks
|
|
*/
|
|
class i18nTextCollectorTask extends BuildTask {
|
|
|
|
protected $title = "i18n Textcollector Task";
|
|
|
|
protected $description = "
|
|
Traverses through files in order to collect the 'entity master tables'
|
|
stored in each module.
|
|
|
|
Parameters:
|
|
- locale: Sets default locale
|
|
- writer: Custom writer class (defaults to i18nTextCollector_Writer_RailsYaml)
|
|
- module: One or more modules to limit collection (comma-separated)
|
|
- merge: Merge new strings with existing ones already defined in language files (default: FALSE)
|
|
";
|
|
|
|
public function init() {
|
|
parent::init();
|
|
|
|
$canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"));
|
|
if(!$canAccess) return Security::permissionFailure($this);
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @uses DataObject->collectI18nStatics()
|
|
*/
|
|
public function run($request) {
|
|
increase_time_limit_to();
|
|
$c = new i18nTextCollector($request->getVar('locale'));
|
|
$writer = $request->getVar('writer');
|
|
if($writer) $c->setWriter(new $writer());
|
|
$restrictModules = ($request->getVar('module')) ? explode(',', $request->getVar('module')) : null;
|
|
return $c->run($restrictModules, (bool)$request->getVar('merge'));
|
|
}
|
|
}
|