Contents
Some of the points in BetterHebrewSupport/Problems could be fixed with release 1.2, which will certainly include some improvements with regard to UTF-8 support (recoding of I18N texts, for example).
- What is i18n recoding?
Sorting page elements to direction by markup
The lang macro will handle paragraph direction and ltr/rtl macros will handle sub paragraph direction?
Then the direction macro could use only the [[ltr()]] syntax to enclose letters inside span tag.
Detecting direction from language
This is the most probable solution for the distribution code, because it also buys us lang attributes for speech interfaces. Each language has a direction associated to it.
There are [[lang]] macros for each language supported in MoinMoin.i18n, which switches language for the text following it (which means you have to switch languages at the end of paragraphs). Also, a default language for the wiki as a whole (config.default_lang).
Default! de
MultiLang hier beschreiben... en
English! he
Hebrew! בעברית
בעברית
בעברית en
Look at this /LangTest to see how the system works
Visit also my personal Hebrew wiki to test the latest MoinMoin from CVS with Hebrew/English pages.
Direction macros
I have written rtl and ltr macros, based on the html.py macro. We are using them now in MacMac. The page is mostly in Hebrew, but you can see the code examples and check the HTML. Can you check this? --NirSoffer
Usage:
[[ltr]] or [[rtl]] to change direction from now untill the next rtl/ltr tag
[[ltr(Text)]] to reverse part of a paragraph. I thought this was not very important, but after using it for few days, it proves to be useful
ltr macro code:
For the rtl code, replace ltr with rtl.
1 """
2 LTR macro - outputs a left to right direction tags
3
4 by Nir Soffer nirs at freeshell.org
5 """
6
7 def execute(macro, text):
8
9 if text:
10 # escape possible HTML in text
11 import cgi
12 text = cgi.escape(text)
13
14 # return span tag around text
15 # todo: use macro.formater for HTML output
16 return '<span dir="ltr">%s</span>' % (text)
17
18 # return div with direction
19 # todo: use macro.formater for HTML output
20 return '<div class="ltr" dir="ltr">'
The div option create sub standard HTML, because the missing </div> tag, but it work on both Mozilla for Mac and Windows and Explorer for Windows
Sorting page elements to direction by magic
This can be done by finding the language of a paragraph by looking at its letters. You can see this solution at Be-o-fen Ti-v-ee (the test page was deleted) As you can see at this site, it works most of the time, but there are situations when only the writer can tell which is the right direction for a text, usually when you mix Hebrew and non-Hebrew letters. I think it's impossible to design a 100% automatic solution for this. I never heard of a word processor that does this.
We could implement this kind of solution, but then we need the directions tags anyway to overcome limits of this solution.
I do not see any point on working on this solution for now. I think that we should first finish the direction markup which is highly needed now, and will be so simple to use for the occasional non-Hebrew content. TitleIndex and WordIndex are both much more important than this.
Granularity of direction
Paragraph direction:
This will be enough for most pages combining Hebrew and non Hebrew content. This is implemented in HTML with the dir attribute of the div, p and other tags.
Sub Paragraph direction:
Controlling part of a paragraph direction is useful in these situations:
- You combine Hebrew, English and letters that do not have direction, like spaces, !, ?, - etc. for example, this paragraph:
English text and וקצת עברית! - sometimes you want the "!" to be on the left side of the Hebrew part.
Hebrew HTML code aligned to the right. This is how I write Hebrew web pages, and to get the HTML tags to display correctly in the editor, I setup the HTML code to have words ltr direction, so end tags like </b> do not look like <b/>. Even this case is only a cosmetic problem - the code works either way.
Using the ltr/rtl marcos like this: [[ltr(some text)]] solves the problem