Exemplo n.º 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();
 }
Exemplo n.º 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 = ["/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);
 }
Exemplo n.º 3
0
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/bootstrap.php';
use Magento\Tools\I18n\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(['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'), ['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);
}
Exemplo n.º 4
0
    $console = new \Zend_Console_Getopt(['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'), ['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);
}