Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make suggestions optional
  • Loading branch information
svineet authored and Kira-D committed Aug 27, 2016
commit 0335afa8836ba2c5129de94b65d863b732ec2b50
37 changes: 37 additions & 0 deletions assets/js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,43 @@ function translateText() {
if(data.responseStatus === HTTP_OK_CODE) {
$('#translatedText').html(data.responseData.translatedText);
$('#translatedText').removeClass('notAvailable text-danger');

$('#translatedText').attr('pristineText', data.responseData.translatedText);

if(config.SUGGESTIONS.enabled === 'True') {
$('#translatedText').html(
$('#translatedText').html().replace(
/(\*\S+|\@\S+|\#\S+)/g,
'<span class="wordSuggestPop text-danger" title="Improve Apertium\'s translation">$1</span>'));
}
$('#translatedTextClone').html(
$('#translatedText').attr('pristineText'));

$('.wordSuggestPop').click(function() {
$('.wordSuggestPop').removeAttr('id');
$('.wordSuggestPopInline').removeAttr('id');
$(this).attr('id', 'wordGettingSuggested');

$('#translatedTextClone').html(
$('#translatedTextClone').html().replace(
/(\*\S+|\@\S+|\#\S+)/g,
'<span class="wordSuggestPopInline text-danger" title="Improve Apertium\'s translation">$1</span>'));

$('.wordSuggestPopInline').click(function() {
$('.wordSuggestPop').removeAttr('id');
$('.wordSuggestPopInline').removeAttr('id');
$(this).attr('id', 'wordGettingSuggested');

$('#suggestionTargetWord').html($(this).text());
$('#suggestedWordInput').val('');
});

console.log(dynamicLocalizations['Suggest_Sentence']);
$('#suggestSentenceContainer').html(
dynamicLocalizations['Suggest_Sentence'].replace('{{targetWordCode}}', '<code><span id="suggestionTargetWord"></span></code>'))
$('#suggestionTargetWord').html($(this).text());
$('#wordSuggestModal').modal();
});
}
else {
translationNotAvailable();
Expand Down
6 changes: 6 additions & 0 deletions config.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ AVAILABLE_LOCALES_CACHE_EXPIRY = 24
# Localisation replacement strings, see assets/strings/*.json for usage:
[REPLACEMENTS]
maintainer = <a href='http://wiki.apertium.org/wiki/Apertium' target='_blank'>Apertium</a>

[SUGGESTIONS]
ENABLED = True
RECAPTCHA_SITE_KEY = None
CONTEXT_WRAP = 5