Skip to content

Commit

Permalink
Manage (#4)
Browse files Browse the repository at this point in the history
* removed editing requirement
* updated documentation
* bumped version
* updated changelog
  • Loading branch information
kalebheitzman authored Mar 4, 2024
1 parent ba7f73c commit 69f2694
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2024030400

- Disabled having to be in edit mode for the manage page

## 2024022202

- Major Refactor
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ You can also find a link in each course to translate only the content found in t

The second scheduled task syncs a local copy of your Autotranslation glossary to DeepL for any [language combinations supported by DeepL.](https://www.deepl.com/docs-api/glossaries). You can manage your glossaries at `/filter/autotranslate/glossary.php`. To create a sync job, you will need to click "Sync Glossary" on the Glossary Management page for the selected source and target language pair.

![Glossary Page](docs/glossary.jpg)

Running from the CLI:

```bash
php admin/cli/scheduled_task.php --execute='\filter_autotranslate\task\sync_glossaries_task'
```

![Glossary Page](docs/glossary.jpg)
## Other Tasks

```bash
# checks that the requested translation has a source text available
php admin/cli/scheduled_task.php --execute='\filter_autotranslate\task\check_source_task'
```
60 changes: 28 additions & 32 deletions classes/output/manage_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,40 +261,36 @@ class="col-5 filter-autotranslate__source-text"
$mform->addElement('html', '<div
class="col-5 filter-autotranslate__target-text ' . $record->target_lang_dir . '"
>');
if ($PAGE->user_is_editing()) {
// Edit mode is on.
$fieldname = 'translation[' . $record->hash . ']';
$fieldname2 = 'original[' . $record->hash . ']';
$ishtml = $this->contains_html($record->text);
if ($ishtml) {
$mform->addElement(
'editor',
$fieldname,
null,
[
'autosave' => false,
'removeorphaneddrafts' => true,
]
)->setValue(['text' => $record->target_text]);
$mform->setType($fieldname, PARAM_RAW);
} else {
$mform->addElement(
'textarea',
$fieldname,
null,
[
'oninput' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"',
'onfocus' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"',
]
);
$mform->setDefault($fieldname, $record->target_text);
}
$mform->addElement('textarea', $fieldname2, null, ["class" => "d-none"]);
$mform->setDefault($fieldname2, $record->target_text);

$fieldname = 'translation[' . $record->hash . ']';
$fieldname2 = 'original[' . $record->hash . ']';
$ishtml = $this->contains_html($record->text);
if ($ishtml) {
$mform->addElement(
'editor',
$fieldname,
null,
[
'autosave' => false,
'removeorphaneddrafts' => true,
]
)->setValue(['text' => $record->target_text]);
$mform->setType($fieldname, PARAM_RAW);
} else {
// Edit mode is off.
$mform->addElement('html', $record->target_text);
$mform->addElement(
'textarea',
$fieldname,
null,
[
'oninput' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"',
'onfocus' => 'this.style.height = "";this.style.height = this.scrollHeight + "px"',
]
);
$mform->setDefault($fieldname, $record->target_text);
}
$mform->addElement('textarea', $fieldname2, null, ["class" => "d-none"]);
$mform->setDefault($fieldname2, $record->target_text);

$mform->addElement('html', '</div>');

// Close translation item.
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024022702; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024030400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2023042400; // Requires this Moodle version.
$plugin->component = 'filter_autotranslate'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_ALPHA;
$plugin->release = '4.3.0 (Build: 2024022702)';
$plugin->release = '4.3.0 (Build: 2024030400)';

0 comments on commit 69f2694

Please sign in to comment.