summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php')
-rw-r--r--www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php b/www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php
new file mode 100644
index 00000000..df1c38d2
--- /dev/null
+++ b/www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Translation aid provider.
+ *
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+/**
+ * Translation aid which gives the current saved translation.
+ *
+ * @ingroup TranslationAids
+ * @since 2013-01-01
+ */
+class CurrentTranslationAid extends TranslationAid {
+ public function getData() {
+ $translation = null;
+
+ $title = $this->handle->getTitle();
+ $translation = TranslateUtils::getMessageContent(
+ $this->handle->getKey(),
+ $this->handle->getCode(),
+ $title->getNamespace()
+ );
+
+ Hooks::run( 'TranslatePrefillTranslation', [ &$translation, $this->handle ] );
+ $fuzzy = MessageHandle::hasFuzzyString( $translation ) || $this->handle->isFuzzy();
+ $translation = str_replace( TRANSLATE_FUZZY, '', $translation );
+
+ return [
+ 'language' => $this->handle->getCode(),
+ 'fuzzy' => $fuzzy,
+ 'value' => $translation,
+ ];
+ }
+}