# right to left in docproj



## bkouhi (Apr 29, 2013)

Hello all,

As you may know, some languages are written from right to left. For example Persian, Hebrew and so on. How can I change the text direction to RTL? I'm unable to find something about this in the official documents.


----------



## cpm@ (May 2, 2013)

@bkouhi,

There are applications that support RTL and Bidi, e.g., if you want to use Persian text in terminal you can use x11/mlterm.

About FreeBSD documentation project in Persian:
http://freebsd.1045724.n5.nabble.com/FreeBSD-Farsi-Persian-Documentation-Translation-Project-td4099526.html.


----------



## bkouhi (May 2, 2013)

Ok, thank you @cpu82.

Let me expand that a little more. Suppose that I have the following book.xml. Sorry for UTF-8 characters.


```
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<book lang='fa'>
  <bookinfo>
    <title>ÛŒÚ© Ú©ØªØ§Ø¨ Ù†Ù…ÙˆÙ†Ù‡</title>

    <author>
      <firstname>Ù†Ø§Ù… Ø´Ù…Ø§</firstname>
      <surname>Ù†Ø§Ù… Ø®Ø§Ù†ÙˆØ§Ø¯Ú¯ÛŒ Ø´Ù…Ø§</surname>
      <affiliation>
        <address><email>foo@example.com</email></address>
      </affiliation>
    </author>

    <copyright>
      <year>2013</year>
      <holder>Ø§Ø·Ù„Ø§Ø¹Ø§Øª Ø­Ù‚ ØªÚ©Ø«ÛŒØ±</holder>
    </copyright>

    <abstract>
      <para>Ø§Ø·Ù„Ø§Ø¹Ø§Øª Ù…Ø±Ø¨ÙˆØ· Ø¨Ù‡ Ú©ØªØ§Ø¨ Ø´Ù…Ø§</para>
    </abstract>
  </bookinfo>

  <preface>
    <title>Ù…Ù‚Ø¯Ù…Ù‡</title>

    <para>Ø§Ú¯Ø± Ú©ØªØ§Ø¨ Ø´Ù…Ø§ Ú© Ù…Ù‚Ø¯Ù…Ù‡ Ø¯Ø§Ø±Ø¯ Ø¯Ø± Ø§ÛŒÙ† Ù‚Ø³Ù…Øª Ø¨Ù†ÙˆÛŒØ³ÛŒØ¯.</para>
  </preface>

  <chapter>
    <title>ÙØµÙ„ Ø§ÙˆÙ„</title>

    <para>Ø§ÛŒÙ† Ø§ÙˆÙ„ÛŒÙ† ÙØµÙ„ Ú©ØªØ§Ø¨ Ø§Ø³Øª.</para>

    <sect1>
      <title>Ø§ÙˆÙ„ÛŒÙ† Ù‚Ø³Ù…Øª.</title>

      <para>Ø§ÛŒÙ† Ø§ÙˆÙ„ÛŒÙ† Ù‚Ø³Ù…Øª Ø§ÛŒÙ† Ú©ØªØ§Ø¨ Ø§Ø³Øª.</para>
    </sect1>
  </chapter>
</book>
```

I have some problems with this book.xml:

1. The build system simply rejects my book.xml and says that:

```
...
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:16:E: non SGML character number 134
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:20:E: non SGML character number 133
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:27:E: non SGML character number 134
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:29:E: non SGML character number 136
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:37:E: non SGML character number 140
/usr/local/bin/openjade:/usr/doc/fa_IR.UTF-8/books/handbook/book.xml:10:42:E: non SGML character number 133
...
```

2. I need to change the text direction to Right-to-Left. So the readers can read it easily. In HTML, most of tags have an attribute named dir. But how about SGML DocBook?

Unfortunately, there's no FreeBSD Persian Documentation Project.


----------



## cpm@ (May 2, 2013)

In XML, the entire range of Unicode characters is available to you, but in SGML, the declaration indicates what characters are valid. The distributed DocBook declaration doesn't allow a bunch of fairly common 8-bit characters. You can fix this by converting them to character entities or by changing the SGML declaration.

If ISO-8859-1 doesn't contain valid characters, probably you have to set the file's encoding to UTF-8.

Add this line in the header of book.xml file.

```
[B]<?xml version="1.0" encoding="UTF-8"?>[/B]
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<book lang='fa'>
  <bookinfo>
    <title>ÛŒÚ© Ú©ØªØ§Ø¨ Ù†Ù…ÙˆÙ†Ù‡</title>

<snip>
```

This post explains how to set text direction for any XML parameter.



			
				bkouhi said:
			
		

> Unfortunately, there's no FreeBSD Persian Documentation Project.



Contact them 

admin@freebsd.net.co
armin.rezayati@gmail.com


----------

