<p>Update: temp fix
as per comments below i fixed with js plugin <a href="https://github.com/lindseydiloreto/craft-cpjs" rel="nofollow">https://github.com/lindseydiloreto/craft-cpjs</a></p>

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

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

private function _getCurrentLocale() {

    $segments = craft()-&gt;request-&gt;segments;
    $lastSegment = end($segments);

    return $lastSegment;

}
</code></pre>

<p>The the extra js settings;</p>

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

<p>});</p>

<p>this will help arabic translators start translating hopefully</p>

CC BY-SA 3.0
2017-02-23T06:30:57.383Z
What solution are you using at the moment for this? Did the craft cpjs plugin still work?
Mark
CC BY-SA 3.0
2016-07-27T16:12:25.100Z
2016-07-27T16:12:25.100Z
joomkit
<p>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)</p>

CC BY-SA 3.0
2016-07-25T21:40:12.687Z
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: https://imperavi.com/redactor/examples/text-direction/
Brad Bell
CC BY-SA 3.0
2016-07-25T21:45:19.047Z
Thanks and yes thats what I want - but where does one put this js?
joomkit
CC BY-SA 3.0
2016-07-25T21:53:31.977Z
When you're instantiating your Redactor instance like in the example?
Brad Bell
CC BY-SA 3.0
2016-07-25T22:03:54.433Z
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
CC BY-SA 3.0
2016-07-25T22:06:37.500Z
Ohh... it will only happen if you're currently viewing the CP in a RTL based language like Arabic.
Brad Bell
CC BY-SA 3.0
2016-07-25T22:10:37.777Z
So it is happening in arabic but only on first load of new page - the english copy is RTL. As soon as I paste arabic from google translate it goes LTR....
joomkit
CC BY-SA 3.0
2016-07-25T22:13:34.777Z
What is weird is toggling HTML button - the raw html is RTL....
joomkit
CC BY-SA 3.0
2016-07-25T22:15:35.420Z
If you think you've found a bug, send in steps to reproduce to support@craftcms.com. I'm able to paste Google Translate Arabic text into a Rich Text field viewing the CP in Arabic and it's RTL as expected.
Brad Bell
CC BY-SA 3.0
2016-07-26T10:07:17.950Z
Email/Bug submitted. For reference made a video demo of issue: http://screencast.com/t/Ilem7uqI
joomkit
CC BY-SA 3.0
2016-07-26T21:36:40.540Z
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
CC BY-SA 3.0
2016-09-02T17:34:43.153Z
ANy update on this bug? My solution has stopped working. The redactor interface shows arabic lef-to-right only despite injected css styles
joomkit
<localization><editor>
Pasting into redactor with Arabic
# Pasting into redactor with Arabic

(Asked by: username_0 on 2016-07-25)

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)

**Tags:** localization, editor

> **Comments:**
> **username_1**: 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: https://imperavi.com/redactor/examples/text-direction/  
> **username_0**: Thanks and yes thats what I want - but where does one put this js?  
> **username_1**: When you're instantiating your Redactor instance like in the example?  
> **username_0**: 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?  
> **username_1**: Ohh... it will only happen if you're currently viewing the CP in a RTL based language like Arabic.  
> **username_0**: So it is happening in arabic but only on first load of new page - the english copy is RTL. As soon as I paste arabic from google translate it goes LTR....  
> **username_0**: What is weird is toggling HTML button - the raw html is RTL....  
> **username_1**: If you think you've found a bug, send in steps to reproduce to support@craftcms.com. I'm able to paste Google Translate Arabic text into a Rich Text field viewing the CP in Arabic and it's RTL as expected.  
> **username_0**: Email/Bug submitted. For reference made a video demo of issue: http://screencast.com/t/Ilem7uqI  
> **username_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.  
> **username_0**: ANy update on this bug? My solution has stopped working. The redactor interface shows arabic lef-to-right only despite injected css styles  

---

## 1 answers

### Answer by username_0 on 2016-07-27. Score: 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);
        }
    }
    //username_0 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

> **Comments:**
> **username_2**: What solution are you using at the moment for this? Did the craft cpjs plugin still work?  

---

