Skip to content

Commit

Permalink
implement CopyLanguageContent
Browse files Browse the repository at this point in the history
This event is meant to give 3rd-party developers the possibility to copy i18n contents in every case contents should be copied to another language.
  • Loading branch information
mutec committed Mar 15, 2023
1 parent 6a66950 commit 53dd5fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use wcf\data\page\PageEditor;
use wcf\system\cache\builder\LanguageCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
use wcf\system\io\AtomicWriter;
use wcf\system\language\event\CopyLanguageContent;
use wcf\system\language\LanguageFactory;
use wcf\system\Regex;
use wcf\system\WCF;
Expand Down Expand Up @@ -1054,5 +1056,10 @@ public static function copyLanguageContent($sourceLanguageID, $destinationLangua
}

PageEditor::resetCache();

EventHandler::getInstance()->fire(new CopyLanguageContent(
LanguageFactory::getInstance()->getLanguage($sourceLanguageID),
LanguageFactory::getInstance()->getLanguage($destinationLanguageID)
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace wcf\system\language\event;

use wcf\data\language\Language;
use wcf\system\event\IEvent;

/**
* Indicates that the contents of a language should be copied to another one.
*
* @author Florian Gail
* @copyright 2001-2023 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.0
*/
final class CopyLanguageContent implements IEvent
{
public function __construct(
public readonly Language $sourceLanguage,
public readonly Language $targetLanguage,
) {
}
}

0 comments on commit 53dd5fc

Please sign in to comment.