Arc Forumnew | comments | leaders | submitlogin
Ask Arc:
4 points by hod 4823 days ago | 2 comments
How do I turn HN-like from right to left (Hebrew support)


4 points by rocketnia 4823 days ago | link

To start out, you can try adding this line to news.css:

  body { direction: rtl; }
The news.css stylesheet isn't actually its own file. It's defined in news.arc like this:

  (defop news.css req
    (pr "
  ...
  "))
When you add that line, the page layout will go from right to left.

You may end up with petty page layout issues that have to be solved on a case-by-case basis.

---

You might have character encoding issues, but probably not. The code in srv.arc announces in an HTTP header that it's serving UTF-8, which it is. But just to be safe, you may want to put a charset declaration in the HTML itself like this:

  ; In html.arc, insert this alongside the other (attribute ...)
  ; declarations:
  (attribute meta charset opstring)
  
  ; In news.arc, add one line:
  (mac npage (title . body)
    `(tag html
       (tag head
         (tag (meta charset "UTF-8"))  ; This is the added line.
         ...)
       ...))
---

Some characters will probably be displayed out of order. This is because HTML and Unicode try to arrange characters by the characters' own directionality, and when characters of different directionality mix, the result is confusing.

The fix is to use special Unicode characters to clearly delineate which parts of the text are ltr and which are rtl: http://www.w3.org/TR/WCAG20-TECHS/H34

I don't know how easy it will be for users to enter these characters (e.g. if they're pasting ASCII code alongside Hebrew text). All I can say is that I hope it's something Hebrew IMEs already support. :/

I'd be glad to hear horror stories or success stories about Hebrew IMEs (or IMEs of any language). :)

---

You might also want to change the page generator to emit <html lang="he">, although I guess I don't see a lot of sites actually doing that. :)

If you do care about the lang attribute, it should be possible to insert it with two lines of code:

  ; In html.arc, insert this alongside the other (attribute ...)
  ; declarations:
  (attribute html lang opstring)
  
  ; In news.arc, change one line:
  (mac npage (title . body)
    `(tag (html lang "he")   ; This is the changed line.
       (tag head
         ...)
       ...))
---

If you'd like to use the lang attribute properly and you have content in multiple languages on one page, you can put lang attributes on the individual elements (http://stackoverflow.com/questions/7076837/what-html-lang-at...).

If you're going to do this, add another (attribute ____ lang opstring) line for each tag name you want to use the lang attribute with.

---

I've done this for an HTML page before, if you can't tell. :-p But I have not used news.arc, so the code I'm suggesting might not work. I hope it gets you started though.

-----

1 point by akkartik 4823 days ago | link

Do you mean moving the vote buttons to the right of titles? Since they're images, and since they're laid out using a table, you would have to reorder columns of the table.

I'm not sure how to test it in a hebrew encoding, but here's an idea. Can you look inside news.arc for a function called display-story, and turn something that looks like this:

  (def display-story (i s user whence)
    (when (or (cansee user s) (s 'kids))
      (tr (display-item-number i)
          (td (votelinks s user whence))
          (titleline s s!url user whence))
      (tr (tag (td colspan (if i 2 1)))
          (tag (td class 'subtext)
            (hook 'itemline s user)
            (itemline s user)
            (when (in s!type 'story 'poll) (commentlink s user))
            (editlink s user)
            (when (apoll s) (addoptlink s user))
            (unless i (flaglink s user whence))
            (killlink s user whence)
            (blastlink s user whence)
            (blastlink s user whence t)
            (deletelink s user whence)))))
Into this:

  (def display-story (i s user whence)
    (when (or (cansee user s) (s 'kids))
      (tr (tag (td colspan (if i 2 1)))
          (tag (td class 'subtext)
            (hook 'itemline s user)
            (itemline s user)
            (when (in s!type 'story 'poll) (commentlink s user))
            (editlink s user)
            (when (apoll s) (addoptlink s user))
            (unless i (flaglink s user whence))
            (killlink s user whence)
            (blastlink s user whence)
            (blastlink s user whence t)
            (deletelink s user whence)))
      (tr (display-item-number i)
          (td (votelinks s user whence))
          (titleline s s!url user whence))
      ))    
Basically I'm swapping the two expressions that begin with tr. Can you try that and see if it works for you?

(The version I have may be slightly different from yours, so just pasting this fragment in may not work.)

Come back and tell us how it went. If it worked, a couple more callers of votelinks will need to be changed as well -- for comments and polls.

-----