Example #1
0
 protected function setUp()
 {
     $this->testDir = realpath(__DIR__ . '/_files');
     $this->expectedDir = $this->testDir . '/expected';
     $this->source = $this->testDir . '/source';
     $this->outputFileName = $this->testDir . '/translate.csv';
     $this->generator = ServiceLocator::getDictionaryGenerator();
 }
Example #2
0
 protected function setUp()
 {
     $this->_testDir = realpath(__DIR__ . '/_files');
     $this->_expectedDir = $this->_testDir . '/expected';
     $this->_dictionaryPath = $this->_testDir . '/source.csv';
     $this->_packPath = $this->_testDir . '/pack';
     $this->_locale = 'de_DE';
     $this->_expectedFiles = array("/app/code/Magento/FirstModule/i18n/{$this->_locale}.csv", "/app/code/Magento/SecondModule/i18n/{$this->_locale}.csv", "/app/design/adminhtml/default/i18n/{$this->_locale}.csv", "/lib/web/i18n/{$this->_locale}.csv");
     $this->_generator = ServiceLocator::getPackGenerator();
     \Magento\Framework\System\Dirs::rm($this->_packPath);
 }
Example #3
0
    $console = new \Zend_Console_Getopt(array('source|s=s' => 'Path to source dictionary file with translations', 'pack|p=s' => 'Path to language package', 'locale|l=s' => 'Target locale for dictionary, for example "de_DE"', 'mode|m-s' => 'Save mode for dictionary
        - "replace" - replace language pack by new one
        - "merge" -  merge language packages, by default "replace"', 'allow_duplicates|d=s' => 'Is allowed to save duplicates of translate, by default "no"'));
    $console->parse();
    if (!count($console->getOptions())) {
        throw new \UnexpectedValueException('Required parameters are missed, please see usage description' . "\n\n" . $console->getUsageMessage());
    }
    $dictionaryPath = $console->getOption('source');
    $packPath = $console->getOption('pack');
    $locale = $console->getOption('locale');
    $allowDuplicates = in_array($console->getOption('allow_duplicates'), array('y', 'Y', 'yes', 'Yes', '1'));
    $saveMode = $console->getOption('mode');
    if (!$dictionaryPath) {
        throw new \Zend_Console_Getopt_Exception('Dictionary source path parameter is required.');
    }
    if (!$packPath) {
        throw new \Zend_Console_Getopt_Exception('Pack path parameter is required.');
    }
    if (!$locale) {
        throw new \Zend_Console_Getopt_Exception('Locale parameter is required.');
    }
    $generator = ServiceLocator::getPackGenerator();
    $generator->generate($dictionaryPath, $packPath, $locale, $saveMode, $allowDuplicates);
    fwrite(STDOUT, sprintf("\nSuccessfully saved %s language package.\n", $locale));
} catch (\Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n\n" . $e->getUsageMessage() . "\n");
    exit(1);
} catch (\Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n");
    exit(1);
}
Example #4
0
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require_once __DIR__ . '/bootstrap.php';
use Magento\Tools\I18n\Code\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(array('directory|d=s' => 'Path to a directory to parse', 'output-file|o=s' => 'Path (with filename) to output file, ' . 'by default output the results into standard output stream', 'magento|m-s' => 'Indicates whether the specified "directory" path is a Magento root directory,' . ' "no" by default'));
    $console->parse();
    if (!count($console->getOptions())) {
        throw new \Zend_Console_Getopt_Exception('Required parameters are missed, please see usage description', $console->getUsageMessage());
    }
    $directory = $console->getOption('directory');
    if (empty($directory)) {
        throw new \Zend_Console_Getopt_Exception('Directory is a required parameter.', $console->getUsageMessage());
    }
    $outputFilename = $console->getOption('output-file') ?: null;
    $isMagento = in_array($console->getOption('magento'), array('y', 'yes', 'Y', 'Yes', 'YES', '1'));
    $generator = ServiceLocator::getDictionaryGenerator();
    $generator->generate($directory, $outputFilename, $isMagento);
    fwrite(STDOUT, "\nDictionary successfully processed.\n");
} catch (\Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n\n" . $e->getUsageMessage() . "\n");
    exit(1);
} catch (\Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n");
    exit(1);
}