Fixed translation upgrade.
This commit is contained in:
@@ -160,9 +160,11 @@ function run_info($args, $opts) {
|
||||
|
||||
function run_workspace_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$first = true;
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
$workspace->upgrade();
|
||||
$workspace->upgrade($first);
|
||||
$first = false;
|
||||
} catch (Exception $e) {
|
||||
echo "Errors upgrading workspace " . info($workspace->name) . ": " . error($e->getMessage()) . "\n";
|
||||
}
|
||||
@@ -171,12 +173,12 @@ function run_workspace_upgrade($args, $opts) {
|
||||
|
||||
function run_translation_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$updateXml = true;
|
||||
$first = true;
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
echo "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n";
|
||||
$workspace->upgradeTranslation($updateXml);
|
||||
$updateXml = false;
|
||||
$workspace->upgradeTranslation($first);
|
||||
$first = false;
|
||||
} catch (Exception $e) {
|
||||
echo "Errors upgrading translation of workspace " . info($workspace->name) . ": " . error($e->getMessage()) . "\n";
|
||||
}
|
||||
@@ -185,7 +187,6 @@ function run_translation_upgrade($args, $opts) {
|
||||
|
||||
function run_cacheview_upgrade($args, $opts) {
|
||||
$workspaces = get_workspaces_from_args($args);
|
||||
$updateXml = true;
|
||||
foreach ($workspaces as $workspace) {
|
||||
try {
|
||||
echo "Upgrading cache view for " . pakeColor::colorize($workspace->name, "INFO") . "\n";
|
||||
|
||||
@@ -243,7 +243,7 @@ class languages {
|
||||
}
|
||||
|
||||
|
||||
public function importLanguage($sLanguageFile, $updateXml = true)
|
||||
public function importLanguage($sLanguageFile, $updateXml = true, $updateDB = true)
|
||||
{
|
||||
try {
|
||||
G::LoadSystem('i18n_po');
|
||||
@@ -294,7 +294,7 @@ class languages {
|
||||
$reference = $POFile->references[0];
|
||||
|
||||
if( $identifier == 'TRANSLATION') {
|
||||
|
||||
if ($updateDB) {
|
||||
list($category, $id) = explode('/', $context);
|
||||
$result = $oTranslation->addTranslation(
|
||||
$category,
|
||||
@@ -304,6 +304,7 @@ class languages {
|
||||
);
|
||||
if( $result['codError'] == 0 )
|
||||
$countItemsSuccess++;
|
||||
}
|
||||
} else if( $updateXml ){
|
||||
$xmlForm = $context;
|
||||
$codes = explode('-', $reference);
|
||||
|
||||
@@ -150,7 +150,7 @@ class System {
|
||||
public static function listPoFiles() {
|
||||
$folders = glob(PATH_CORE . '/content/translations/*');
|
||||
|
||||
$items = glob(PATH_CORE . '/content/*.po');
|
||||
$items = glob(PATH_CORE . '/content/translations/*.po');
|
||||
foreach ($folders as $folder) {
|
||||
if (is_dir($folder)) {
|
||||
$add = glob($folder . "/*.po");
|
||||
|
||||
@@ -256,14 +256,23 @@ class workspaceTools {
|
||||
*
|
||||
* @param bool $updateXml if true, update the xmlforms
|
||||
*/
|
||||
public function upgradeTranslation($updateXml = true) {
|
||||
public function upgradeTranslation($first = true) {
|
||||
$this->initPropel(true);
|
||||
G::LoadClass('languages');
|
||||
G::LoadThirdParty('pear/json', 'class.json');
|
||||
$languages = new languages();
|
||||
foreach (System::listPoFiles() as $poFile) {
|
||||
CLI::logging("Updating language ".basename($poFile)."\n");
|
||||
$languages->importLanguage($poFile, $updateXml);
|
||||
$poName = basename($poFile);
|
||||
$names = explode(".", basename($poFile));
|
||||
$extension = array_pop($names);
|
||||
$langid = array_pop($names);
|
||||
if (strcasecmp($langid, "en") == 0) {
|
||||
CLI::logging("Updating database translations with $poName\n");
|
||||
$languages->importLanguage($poFile, false, true);
|
||||
} else if ($first) {
|
||||
CLI::logging("Updating XML form translations with $poName\n");
|
||||
$languages->importLanguage($poFile, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user