Fixed translation upgrade.
This commit is contained in:
@@ -160,9 +160,11 @@ function run_info($args, $opts) {
|
|||||||
|
|
||||||
function run_workspace_upgrade($args, $opts) {
|
function run_workspace_upgrade($args, $opts) {
|
||||||
$workspaces = get_workspaces_from_args($args);
|
$workspaces = get_workspaces_from_args($args);
|
||||||
|
$first = true;
|
||||||
foreach ($workspaces as $workspace) {
|
foreach ($workspaces as $workspace) {
|
||||||
try {
|
try {
|
||||||
$workspace->upgrade();
|
$workspace->upgrade($first);
|
||||||
|
$first = false;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "Errors upgrading workspace " . info($workspace->name) . ": " . error($e->getMessage()) . "\n";
|
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) {
|
function run_translation_upgrade($args, $opts) {
|
||||||
$workspaces = get_workspaces_from_args($args);
|
$workspaces = get_workspaces_from_args($args);
|
||||||
$updateXml = true;
|
$first = true;
|
||||||
foreach ($workspaces as $workspace) {
|
foreach ($workspaces as $workspace) {
|
||||||
try {
|
try {
|
||||||
echo "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n";
|
echo "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n";
|
||||||
$workspace->upgradeTranslation($updateXml);
|
$workspace->upgradeTranslation($first);
|
||||||
$updateXml = false;
|
$first = false;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "Errors upgrading translation of workspace " . info($workspace->name) . ": " . error($e->getMessage()) . "\n";
|
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) {
|
function run_cacheview_upgrade($args, $opts) {
|
||||||
$workspaces = get_workspaces_from_args($args);
|
$workspaces = get_workspaces_from_args($args);
|
||||||
$updateXml = true;
|
|
||||||
foreach ($workspaces as $workspace) {
|
foreach ($workspaces as $workspace) {
|
||||||
try {
|
try {
|
||||||
echo "Upgrading cache view for " . pakeColor::colorize($workspace->name, "INFO") . "\n";
|
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 {
|
try {
|
||||||
G::LoadSystem('i18n_po');
|
G::LoadSystem('i18n_po');
|
||||||
@@ -294,16 +294,17 @@ class languages {
|
|||||||
$reference = $POFile->references[0];
|
$reference = $POFile->references[0];
|
||||||
|
|
||||||
if( $identifier == 'TRANSLATION') {
|
if( $identifier == 'TRANSLATION') {
|
||||||
|
if ($updateDB) {
|
||||||
list($category, $id) = explode('/', $context);
|
list($category, $id) = explode('/', $context);
|
||||||
$result = $oTranslation->addTranslation(
|
$result = $oTranslation->addTranslation(
|
||||||
$category,
|
$category,
|
||||||
$id,
|
$id,
|
||||||
$LOCALE,
|
$LOCALE,
|
||||||
trim(str_replace(chr(10), '', stripslashes($rowTranslation['msgstr'])))
|
trim(str_replace(chr(10), '', stripslashes($rowTranslation['msgstr'])))
|
||||||
);
|
);
|
||||||
if( $result['codError'] == 0 )
|
if( $result['codError'] == 0 )
|
||||||
$countItemsSuccess++;
|
$countItemsSuccess++;
|
||||||
|
}
|
||||||
} else if( $updateXml ){
|
} else if( $updateXml ){
|
||||||
$xmlForm = $context;
|
$xmlForm = $context;
|
||||||
$codes = explode('-', $reference);
|
$codes = explode('-', $reference);
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class System {
|
|||||||
public static function listPoFiles() {
|
public static function listPoFiles() {
|
||||||
$folders = glob(PATH_CORE . '/content/translations/*');
|
$folders = glob(PATH_CORE . '/content/translations/*');
|
||||||
|
|
||||||
$items = glob(PATH_CORE . '/content/*.po');
|
$items = glob(PATH_CORE . '/content/translations/*.po');
|
||||||
foreach ($folders as $folder) {
|
foreach ($folders as $folder) {
|
||||||
if (is_dir($folder)) {
|
if (is_dir($folder)) {
|
||||||
$add = glob($folder . "/*.po");
|
$add = glob($folder . "/*.po");
|
||||||
|
|||||||
@@ -256,14 +256,23 @@ class workspaceTools {
|
|||||||
*
|
*
|
||||||
* @param bool $updateXml if true, update the xmlforms
|
* @param bool $updateXml if true, update the xmlforms
|
||||||
*/
|
*/
|
||||||
public function upgradeTranslation($updateXml = true) {
|
public function upgradeTranslation($first = true) {
|
||||||
$this->initPropel(true);
|
$this->initPropel(true);
|
||||||
G::LoadClass('languages');
|
G::LoadClass('languages');
|
||||||
G::LoadThirdParty('pear/json', 'class.json');
|
G::LoadThirdParty('pear/json', 'class.json');
|
||||||
$languages = new languages();
|
$languages = new languages();
|
||||||
foreach (System::listPoFiles() as $poFile) {
|
foreach (System::listPoFiles() as $poFile) {
|
||||||
CLI::logging("Updating language ".basename($poFile)."\n");
|
$poName = basename($poFile);
|
||||||
$languages->importLanguage($poFile, $updateXml);
|
$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