Skip to content

Commit

Permalink
Merge pull request SimpleMachines#6362 from dragomano/sceditor_langs
Browse files Browse the repository at this point in the history
Load missing lang vars for SCEditor
  • Loading branch information
live627 authored Nov 24, 2020
2 parents 6c220ac + 83950c8 commit 6ad9329
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 43 deletions.
61 changes: 20 additions & 41 deletions Sources/Subs-Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1378,46 +1378,6 @@ function legalise_bbc($text)
return $text;
}

/**
* Creates the javascript code for localization of the editor (SCEditor)
*/
function loadLocale()
{
global $context, $txt, $editortxt, $modSettings;

loadLanguage('Editor');

$context['template_layers'] = array();
// Lets make sure we aren't going to output anything nasty.
@ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@ob_start('ob_gzhandler');
else
@ob_start();

// If we don't have any locale better avoid broken js
if (empty($txt['lang_locale']))
die();

$file_data = '(function ($) {
\'use strict\';
$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
foreach ($editortxt as $key => $val)
$file_data .= '
' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';

$file_data .= '
dateFormat: "day.month.year"
}
})(jQuery);';

// Make sure they know what type of file we are.
header('content-type: text/javascript');
echo $file_data;
obExit(false);
}

/**
* Retrieves a list of message icons.
* - Based on the settings, the array will either contain a list of default
Expand Down Expand Up @@ -1563,6 +1523,25 @@ function create_control_richedit($editorOptions)
loadJavaScriptFile('editor.js', array('minimize' => true), 'smf_editor');
loadJavaScriptFile('jquery.sceditor.bbcode.min.js', array(), 'smf_sceditor_bbcode');
loadJavaScriptFile('jquery.sceditor.smf.js', array('minimize' => true), 'smf_sceditor_smf');

$scExtraLangs = '
$.sceditor.locale["' . $txt['lang_dictionary'] . '"] = {
"Width (optional):": "' . $editortxt['width'] . '",
"Height (optional):": "' . $editortxt['height'] . '",
"Insert": "' . $editortxt['insert'] . '",
"Description (optional):": "' . $editortxt['description'] . '",
"Rows:": "' . $editortxt['rows'] . '",
"Cols:": "' . $editortxt['cols'] . '",
"URL:": "' . $editortxt['url'] . '",
"E-mail:": "' . $editortxt['email'] . '",
"Video URL:": "' . $editortxt['video_url'] . '",
"More": "' . $editortxt['more'] . '",
"Close": "' . $editortxt['close'] . '",
dateFormat: "' . $editortxt['dateformat'] . '"
}';

addInlineJavaScript($scExtraLangs, true);

addInlineJavaScript('
var smf_smileys_url = \'' . $settings['smileys_url'] . '\';
var bbc_quote_from = \'' . addcslashes($txt['quote_from'], "'") . '\';
Expand Down Expand Up @@ -1602,7 +1581,7 @@ function create_control_richedit($editorOptions)
'bbc_level' => !empty($editorOptions['bbc_level']) ? $editorOptions['bbc_level'] : 'full',
'preview_type' => isset($editorOptions['preview_type']) ? (int) $editorOptions['preview_type'] : 1,
'labels' => !empty($editorOptions['labels']) ? $editorOptions['labels'] : array(),
'locale' => !empty($txt['lang_locale']) && substr($txt['lang_locale'], 0, 5) != 'en_US' ? $txt['lang_locale'] : '',
'locale' => !empty($txt['lang_dictionary']) && $txt['lang_dictionary'] != 'en' ? $txt['lang_dictionary'] : '',
'required' => !empty($editorOptions['required']),
);

Expand Down
2 changes: 2 additions & 0 deletions Themes/default/languages/Editor.english.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$editortxt['insert_email'] = 'Insert an email';
$editortxt['url'] = 'URL:';
$editortxt['insert_link'] = 'Insert a link';
$editortxt['description'] = 'Description (optional)';
$editortxt['unlink'] = 'Unlink';
$editortxt['more'] = 'More';
$editortxt['close'] = 'Close';
Expand All @@ -59,5 +60,6 @@
$editortxt['float_left'] = 'Float left';
$editortxt['float_right'] = 'Float right';
$editortxt['maximize'] = 'Maximize';
$editortxt['dateformat'] = 'month/day/year';

?>
2 changes: 0 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ function smf_main()
'helpadmin' => true,
'jsoption' => true,
'likes' => true,
'loadeditorlocale' => true,
'modifycat' => true,
'pm' => array('sa' => array('popup')),
'profile' => array('area' => array('popup', 'alerts_popup', 'download', 'dlattach')),
Expand Down Expand Up @@ -345,7 +344,6 @@ function smf_main()
'jsmodify' => array('Post.php', 'JavaScriptModify'),
'jsoption' => array('Themes.php', 'SetJavaScript'),
'likes' => array('Likes.php', 'Likes::call#'),
'loadeditorlocale' => array('Subs-Editor.php', 'loadLocale'),
'lock' => array('Topic.php', 'LockTopic'),
'lockvoting' => array('Poll.php', 'LockVoting'),
'login' => array('LogInOut.php', 'Login'),
Expand Down

0 comments on commit 6ad9329

Please sign in to comment.