1

IS there a way of getting redactor to accept text pasted from arabic in a right to left flow? Should this be solved with custom style for editor based on locale? (Am already doing RTL direction in front end based on locale)

11
  • Is this on the front-end of the site? This should already be happening in the control panel. If so, sounds like you're looking for: imperavi.com/redactor/examples/text-direction
    – Brad Bell
    Jul 25 '16 at 21:40
  • Thanks and yes thats what I want - but where does one put this js?
    – joomkit
    Jul 25 '16 at 21:45
  • When you're instantiating your Redactor instance like in the example?
    – Brad Bell
    Jul 25 '16 at 21:53
  • This is the CPanel editing content not the front end. So its not already happening in the rich text field editing in the control panel - which it should?
    – joomkit
    Jul 25 '16 at 22:03
  • 1
    The bug is what if you're viewing the CP in English, but editing an Arabic entry, then the Rich Text field (and Plain Text for that matter) should display in RTL. Right now it is based on the locale you're viewing the CP in. We plan to have this fixed in Craft 3.
    – Brad Bell
    Jul 26 '16 at 21:36
1

Update: temp fix as per comments below i fixed with js plugin https://github.com/lindseydiloreto/craft-cpjs

Rough and ready hack to only run extra js when editing arabic entry. On CpjsPlugin.php I edited the bottom:

 private function _renderJs()
 {
    $settings = $this->getSettings();
    if (trim($settings->jsFile)) {
        $filepath = craft()->config->parseEnvironmentString($settings->jsFile);
        if ($hash = @sha1_file($filepath)) {
            craft()->templates->includeJsFile($filepath.'?e='.$hash);
        } else {
            craft()->templates->includeJsFile($filepath);
        }
    }
    //joomkit hack for arabic redactor  fix
    $lang =  $this->_getCurrentLocale();
    //only add extra js if arabic is set in url
    if($lang == "ar"){ 
        craft()->templates->includeJs($settings->additionalJs);
    }    
}

private function _getCurrentLocale() {

    $segments = craft()->request->segments;
    $lastSegment = end($segments);

    return $lastSegment;

}

The the extra js settings;

$(function()
{
$('.redactor-editor>*').css({
    direction: 'rtl',
    float: 'right'
});
$('.input #title').css({
    direction: 'rtl',
    float: 'right'
});

});

this will help arabic translators start translating hopefully

1
  • What solution are you using at the moment for this? Did the craft cpjs plugin still work?
    – Mark
    Feb 23 '17 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.