Index: branches/RC/core/units/languages/languages_event_handler.php
===================================================================
diff -u -r11623 -r11674
--- branches/RC/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 11623)
+++ branches/RC/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 11674)
@@ -16,6 +16,7 @@
'OnExportLanguage' => Array('self' => 'advanced:export'),
'OnExportProgress' => Array('self' => 'advanced:export'),
'OnReflectMultiLingualFields' => Array ('self' => 'view'),
+ 'OnSynchronizeLanguages' => Array ('self' => 'edit'),
'OnItemBuild' => Array('self' => true),
);
@@ -357,6 +358,60 @@
}
}
+ /**
+ * Copy missing phrases across all system languages (starting from primary)
+ *
+ * @param kEvent $event
+ */
+ function OnSynchronizeLanguages(&$event)
+ {
+ // get language list with primary language first
+ $sql = 'SELECT LanguageId
+ FROM ' . TABLE_PREFIX . 'Language
+ ORDER BY PrimaryLang DESC';
+
+ $source_langs = $this->Conn->GetCol($sql);
+ $target_langs = $source_langs;
+
+ foreach ($source_langs as $source_id) {
+ foreach ($target_langs as $target_id) {
+ if ($source_id == $target_id) {
+ continue;
+ }
+
+ $this->_addMissingPhrase($source_id, $target_id);
+ }
+ }
+ }
+
+ /**
+ * Copy missing phrases from $from_lang to $to_lang
+ *
+ * @param int $from_lang
+ * @param int $to_lang
+ */
+ function _addMissingPhrase($from_lang, $to_lang)
+ {
+ $tmp_name = TABLE_PREFIX . 'PhraseCopy_' . $this->Application->GetSID();
+ $q = 'CREATE TABLE ' . $tmp_name . '
+ SELECT
+ source.Phrase,
+ source.Translation,
+ source.PhraseType,
+ NULL As PhraseId,
+ ' . $to_lang . ' AS LanguageId,
+ source.LastChanged,
+ source.LastChangeIP,
+ source.Module
+ FROM ' . TABLE_PREFIX . 'Phrase source
+ WHERE source.LanguageId = ' . $from_lang . '
+ AND source.Phrase NOT IN (SELECT Phrase FROM ' . TABLE_PREFIX . 'Phrase target WHERE target.LanguageId = ' . $to_lang . ')';
+ $this->Conn->Query($q);
+
+ $this->Conn->Query('INSERT INTO ' . TABLE_PREFIX . 'Phrase SELECT * FROM ' . $tmp_name);
+ $this->Conn->Query('DROP TABLE ' . $tmp_name);
+ }
+
}
?>
\ No newline at end of file
Index: branches/RC/core/install/english.lang
===================================================================
diff -u -r11661 -r11674
--- branches/RC/core/install/english.lang (.../english.lang) (revision 11661)
+++ branches/RC/core/install/english.lang (.../english.lang) (revision 11674)
@@ -1572,6 +1572,7 @@
UmVzY2FuIFRoZW1lcw==
UmVzZXQ=
UHJpbWFyeQ==
+ U3luY2hyb25pemU=
VXA=
Vmlldw==
U2hvdw==
@@ -2285,6 +2286,7 @@
U2V0IFByaW1hcnkgTGFuZ3VhZ2U=
U2hvdyBNZW51
Q2FuY2Vs
+ U3luY2hyb25pemUgTGFuZ3VhZ2Vz
VG9vbHM=
VXAgYSBDYXRlZ29yeQ==
VmFsaWRhdGU=
Index: branches/RC/core/admin_templates/regional/languages_list.tpl
===================================================================
diff -u -r11623 -r11674
--- branches/RC/core/admin_templates/regional/languages_list.tpl (.../languages_list.tpl) (revision 11623)
+++ branches/RC/core/admin_templates/regional/languages_list.tpl (.../languages_list.tpl) (revision 11674)
@@ -45,6 +45,11 @@
}
) );
+ a_toolbar.AddButton( new ToolBarButton('refresh', '::', function() {
+ submit_event('lang', 'OnSynchronizeLanguages');
+ }
+ ));
+
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
a_toolbar.AddButton( new ToolBarButton('view', '', function() {