diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-09-28 15:50:24 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-09-28 15:50:24 +0000 |
commit | 13cbd89066dce59c444d85551ed376435a7a5e11 (patch) | |
tree | 24ba927f533615da91fb22a04f4160c8a4144999 | |
parent | 5b6449289b92bef21551ff820d2560d6de0f6fbc (diff) | |
download | ellinika-13cbd89066dce59c444d85551ed376435a7a5e11.tar.gz ellinika-13cbd89066dce59c444d85551ed376435a7a5e11.tar.bz2 |
Use lingua (xmltools) instead
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@172 941c8c0f-9102-463b-b60b-cd22ce0e6858
-rw-r--r-- | xtrans/.cvsignore | 2 | ||||
-rw-r--r-- | xtrans/LINGUA.html.xtrans | 946 | ||||
-rw-r--r-- | xtrans/Makefile.am | 1 | ||||
-rw-r--r-- | xtrans/i18n.inc | 48 |
4 files changed, 0 insertions, 997 deletions
diff --git a/xtrans/.cvsignore b/xtrans/.cvsignore deleted file mode 100644 index 3dda729..0000000 --- a/xtrans/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile diff --git a/xtrans/LINGUA.html.xtrans b/xtrans/LINGUA.html.xtrans deleted file mode 100644 index 90e6873..0000000 --- a/xtrans/LINGUA.html.xtrans +++ /dev/null @@ -1,946 +0,0 @@ -# -*- mode: indented-text -*- -# Copyright (C) 2004 Sergey Poznyakoff -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -Import: copy -Import: string -Import: posix - -Include: i18n.inc - -# Index of the current item withing the item group (e.g. ROW, -# ENUMERATE, etc -Global: item_index -0 - -# Index of the current row within the row group (TABULAR) -Global: row_index -0 - -# Maximum number of items per row in the current table -Global: max_items -0 - -# Row index of the last separator row in the current table -Global: separator_row -0 - -Global: rowspan_end -0 - -# Dictionary of file name translations -Global: translist -{} - -# Dictionary of cross-reference identifiers -Global: id_table -{} - -# Override the default file name creation method -Function: create_file_name l, base - """Create new output file name""" - if xtrans.attr["LINGUA"].has_key("LANG"): - lang = xtrans.attr["LINGUA"]["LANG"] + "/" - else: - lang = "" - a = xtrans.get_attribute("PAGENO") - if a == None: - return "%s%s.%s" % (lang, base, xtrans.targetformat) - else: - n = a["PAGENO"] - a["PAGENO"] = n + 1 - if n == 0: - return "%s%s.%s" % (lang, base, xtrans.targetformat) - else: - return "%s%s_%02d.%s" % (lang, base, n, xtrans.targetformat) - -Function: translate_name name - if xtrans.translist.has_key(name): - return xtrans.translist[name] - return name - -Function: translate_name_id n - return xtrans.translate_name(xtrans.filenames[n]) - -# Encode the UTF-8 WORD into the hex notation suitable for passing it -# as a GET argument to the CGI invocation. -Function: dict_encode_string word - str = "" - for i in range(len(word)): - if ord(word[i]) > 127: - str = str + "%" + hex(ord(word[i]))[2:] - else: - str = str + word[i] - return str - -Function: get_attribute name, attr=None - if attr != None and attr.has_key(name): - return attr - for i in range(len(xtrans.tagstack),0,-1): - if xtrans.attr.has_key(xtrans.tagstack[i-1]) \ - and xtrans.attr[xtrans.tagstack[i-1]].has_key(name): - return xtrans.attr[xtrans.tagstack[i-1]] - return None - -Function: get_attrval name, defval, attr=None - a = xtrans.get_attribute(name, attr) - if a == None: - return defval - return a[name] - -# Expand quoted tags in TEXT. Quoted tags are tags in the form {TAG}{/TAG} -# This is a way to compensate for lack of proper quoting and recursive tags (a la m4). -# Some time later I should definitely add both features to eXtrans. -# FIXME: 1) Tag delimiters are hardcoded. -# 2) The function ignores any attributes in tags -Function: expand_text text - r = re.compile("{(\w+)}", re.UNICODE); - e = re.compile("{/(\w+)}", re.UNICODE); - while 1: - m = r.search(text) - if m: - xtrans.output.write(text[:m.start()]) - text = text[m.end():] - # FIXME: Attrs - xtrans.finish_starttag(m.group(1), {}) - k = e.search(text) - if k: - xtrans.content[k.group(1)] = text[:k.start()] - xtrans.finish_endtag(k.group(1)) - else: - raise "Not found end tag for " + m.group(1) - text = text[k.end():] - continue - else: - break - xtrans.output.write(text) - - -# Create a template for a page -Function: PageTemplate title - xtrans.output.write(""" -<BODY> -<TABLE class="main" WIDTH="99%" ALIGN="CENTER" CELLSPACING="0" CELLPADDING="10%" RULES="COLS"> -<TR> - <TD VALIGN=top CLASS="contentpanel"> - <H1 ALIGN=CENTER>""") - xtrans.expand_text(title) - xtrans.output.write("""</H1> -<HR> -""") - - -# Create and open a new page -Function: OpenPage title, prefix - xtrans.SetLocale(xtrans.attr["LINGUA"]["LANG"]) - xtrans.set_output(title, prefix) - if xtrans.content.has_key("AUTHOR") and xtrans.attr["AUTHOR"].has_key("EMAIL"): - xtrans.email = xtrans.attr["AUTHOR"]["EMAIL"] - else: - xtrans.email = "gray@gnu.org" - if xtrans.attr["LINGUA"].has_key("BASE"): - base = xtrans.attr["LINGUA"]["BASE"] - else: - base = xtrans.environ['BASE_HREF'] - hb = """ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<HTML> -<HEAD> - <TITLE>%s</TITLE> - <LINK REV="made" HREF="mailto:%s"> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"> - <META NAME="GENERATOR" CONTENT="%s"> - <META NAME="keywords" LANG="%s" CONTENT="%s"> - <META NAME="ROBOTS" CONTENT="INDEX,NOFOLLOW"> - <BASE HREF="%s"> - <LINK REL="stylesheet" TYPE="text/css" HREF="%s"> -</HEAD> -""" - xtrans.output.write(hb % (title, - xtrans.email, - xtrans.generator, - xtrans.attr["LINGUA"]["LANG"], - xtrans.content["KEYWORDS"], - base, - xtrans.prefix("mainstyle.css"))) - if xtrans.attr["PAGE"].has_key("HEADER"): - title = xtrans.attr["PAGE"]["HEADER"] - xtrans.PageTemplate(title) - -Function: ClosePage - xtrans.output.write(""" - </TD> - <TD class="navbar" VALIGN=TOP width="20%%"> - <IMG SRC="graphics/gnu-head-sm.jpg" ALIGN="top" ALT=" [A GNU head] "><P> - <TABLE class="navbar" WIDTH="100%%" ALIGN="LEFT" CELLSPACING="0" CELLPADDING="10%%" BORDER="0"> - [TOC] - - <TR><TD class="group"><DIV ALIGN="CENTER">%s</DIV></TD></TR> - <TR><TD><A HREF="%s">%s</A></TD></TR> - <TR><TD><A HREF="http://validator.w3.org/check/referer"> - <img border="0" src="graphics/valid-html401.png" - alt="[ Valid HTML 4.01! ]" height="31" width="88"></A></TD></TR> - - <TR><TD><a href="http://jigsaw.w3.org/css-validator/check/referer"> - <img border="0" src="graphics/valid-css.png" - alt="[ Valid CSS! ]" height="31" width="88"></A></TD></TR> - - </TABLE> - </TD> -</TR> -<TR> - <TD colspan=\"2\"> - <hr>""" - % (xtrans.gettext("Information"), - xtrans.attr["AUTHOR"]["HOMEPAGE"], - xtrans.gettext("Home Page"))) - - if xtrans.attr["PAGE"].has_key("BOTTOM"): - xtrans.output.write("\n") - xtrans.output.write(xtrans.attr["PAGE"]["BOTTOM"]) - xtrans.output.write("\n<br>\n") - - xtrans.output.write(""" -%s <A HREF="mailto:%s">%s</A>; - - </TD> -</TR> -</TABLE> -</BODY></HTML> -""" - % ( - xtrans.gettext("For information about this site contact"), - xtrans.attr["AUTHOR"]["EMAIL"], - xtrans.attr["AUTHOR"]["CONTACT"])) - -Starttag: LINGUA - def dictref(x=xtrans): - return '/cgi-bin/dict.cgi?LANG=' + \ - x.attr["LINGUA"]["LANG"] + \ - '_' + \ - x.attr["LINGUA"]["TER"] - - def navigation(fn, x=xtrans): - if fn > 0: - x.put_menu_item(0, x.translate_name_id(fn-1), - x.gettext("Previous Page")) - if fn + 1 < len(x.filenames): - x.put_menu_item(0, x.translate_name_id(fn+1), - x.gettext("Next Page")) - - - xtrans.attr["LINGUA"]["DICT"] = dictref - xtrans.attr["LINGUA"]["NAVIGATION"] = navigation - xtrans.attr["LINGUA"]["MENU"] = [] - -Endtag: LINGUA - pass - - -Starttag: MSGSTR - pass - -Endtag: MSGSTR - xtrans.msgid(xtrans.attr["MSGSTR"]["ID"], xtrans.content["MSGSTR"]) - -Starttag: TITLE nostrip - if xtrans.is_parent("TABULAR"): - xtrans.put('<CAPTION>') - -Endtag: TITLE - if xtrans.is_parent("TABULAR"): - xtrans.put('</CAPTION>') - -Function: get_prefix attr, defval - return xtrans.get_attrval("PREFIX", defval, attr) - -Function: menu_append_ref filename, label - menu = xtrans.attr[xtrans.tagstack[-1]]["MENU"] - menu.append([0, filename, label]) - -Function: menu_append_menu submenu, label - menu = xtrans.attr[xtrans.tagstack[-1]]["MENU"] - menu.append([1, submenu, label]) - -Function: menu_append_function name - menu = xtrans.attr[xtrans.tagstack[-1]]["MENU"] - menu.append([2, name]) - -Starttag: PAGE - xtrans.OpenPage(xtrans.attr["PAGE"]["TITLE"], - xtrans.get_prefix(xtrans.attr["PAGE"], "prefix")) - if xtrans.attr["PAGE"].has_key("REF"): - name = xtrans.attr["PAGE"]["REF"] - ref = xtrans.attr["LINGUA"][name]() - xtrans.translist[xtrans.filenames[-1]] = ref - else: - ref = xtrans.filenames[-1] - if xtrans.attr["PAGE"].has_key("HEADER"): - label = xtrans.attr["PAGE"]["HEADER"] - else: - label = xtrans.labels[-1] - xtrans.menu_append_ref(ref, label) - xtrans.attr["PAGE"]["MENU"] = [] - - -Function: has_group - for i in range(len(xtrans.tagstack)-1,0,-1): - if xtrans.tagstack[i] == "GROUP": - return 1 - return 0 - -Endtag: PAGE - xtrans.ClosePage() - - -Function: begin_block attr - if attr.has_key("ID"): - xtrans.put('<A NAME="%s"></A>\n' % attr["ID"]) - if xtrans.id_table.has_key(attr["ID"]): - raise "ID already defined: " + attr["ID"] - xtrans.id_table[attr["ID"]] = xtrans.filenames[-1] - -Starttag: CHAPTER - xtrans.begin_block(xtrans.attr["CHAPTER"]) - xtrans.attr["CHAPTER"]["PAGENO"]=0 - xtrans.attr["CHAPTER"]["MENU"] = [] - -Endtag: CHAPTER - xtrans.menu_append_menu(xtrans.attr["CHAPTER"]["MENU"], "") - -Starttag: SECTION - xtrans.begin_block(xtrans.attr["SECTION"]) - -Endtag: SECTION - xtrans.put("<HR>") - -Starttag: SUBSECTION - xtrans.begin_block(xtrans.attr["SUBSECTION"]) - -Starttag: SUBSUBSECTION - xtrans.begin_block(xtrans.attr["SUBSUBSECTION"]) - -Starttag: PAGEGROUP - if xtrans.attr["PAGEGROUP"].has_key("PREFIX"): - xtrans.attr["PAGEGROUP"]["PAGENO"]=0 - xtrans.attr["PAGEGROUP"]["MENU"] = [] - -Endtag: PAGEGROUP - xtrans.menu_append_menu(xtrans.attr["PAGEGROUP"]["MENU"], "") - -Starttag: GROUP - xtrans.attr["GROUP"]["MENU"] = [] - -Endtag: GROUP - if not xtrans.attr["GROUP"].has_key("HIDDEN"): - xtrans.menu_append_menu(xtrans.attr["GROUP"]["MENU"], - xtrans.attr["GROUP"]["TITLE"]) - -Endtag: DFN - xtrans.put('<EM>%s</EM>' % xtrans.content["DFN"]) - -Endtag: CMD - xtrans.put('<CODE>%s</CODE>' % xtrans.content["CMD"]) - - -Endtag: PROG - xtrans.put('<B>%s</B>' % xtrans.content["PROG"]) - -Endtag: QUOTE - xtrans.put('<I>%s</I>' % xtrans.content["QUOTE"]) - -# UNUSED? -Function: canonical_name file - s = file[len(xtrans.targetdir):] - if s[0] == '/': - s = s[1:] - return s - -Starttag: XREF - if xtrans.attr["XREF"].has_key("URL"): - xtrans.put("<A HREF=\"%s\">" % xtrans.attr["XREF"]["URL"]) - elif xtrans.id_table.has_key(xtrans.attr["XREF"]["REF"]): - fname = xtrans.id_table[xtrans.attr["XREF"]["REF"]] - xtrans.put('<A HREF="') - if fname != xtrans.filenames[-1]: - xtrans.put(xtrans.prefix(xtrans.translate_name(fname))) - xtrans.put('#%s">' % xtrans.attr["XREF"]["REF"]) - else: - raise "Undefined or forward reference " + xtrans.attr["XREF"]["REF"] - -Endtag: XREF - xtrans.put("</A>") - -Starttag: PARA nostrip - xtrans.put("\n<P>") - -Endtag: PARA - # FIXME: This may generate empty <P> blocks - if not xtrans.attr["PARA"].has_key("__CLOSED__"): - xtrans.put("</P>\n") - -Starttag: HEADER nostrip - if xtrans.is_parent("SECTION"): - n = 2 - elif xtrans.is_parent("SUBSECTION"): - n = 3 - elif xtrans.is_parent("SUBSUBSECTION"): - n = 4 - else: - n = 1 - xtrans.begin_block(xtrans.attr["HEADER"]) - xtrans.output.write('\n<H%d ALIGN="CENTER">' % n) - -Endtag: HEADER - if xtrans.is_parent("SECTION"): - n = 2 - elif xtrans.is_parent("SUBSECTION"): - n = 3 - elif xtrans.is_parent("SUBSUBSECTION"): - n = 4 - else: - n = 1 - xtrans.output.write("</H%d>\n" % n) - -Starttag: ITEMIZE - xtrans.put("<DL>") - -Endtag: ITEMIZE - xtrans.put("</DL>") - -# Split the given text string at split delimiters. Print each part -# except the first one in bold face and indent it one space from -# the previous one -Function: item_split text - if xtrans.attr["TABULAR"].has_key("SPLIT"): - delim = xtrans.attr["TABULAR"]["SPLIT"] - str = "" - for s in text.split(delim): - if str == "" : - str = s - else: - str = str + " <B>" + s + "</B>" - return str; - return text - -# Print the contents of the current item using splitting rules. -# SPLIT attribute introduces a split delimiter. -# OR attribute introduces an "or" delimiter -Function: item_text - if xtrans.attr["TABULAR"].has_key("OR"): - delim = xtrans.attr["TABULAR"]["OR"] - str = "" - for s in xtrans.content["ITEM"].split(delim): - if str == "" : - str = xtrans.item_split(s) - else: - str = str + " " + delim + " " + xtrans.item_split(s) - return str; - else: - return xtrans.item_split(xtrans.content["ITEM"]) - -# Remove any split delimiters from the given text string -Function: restore_single_word text - if xtrans.attr["TABULAR"].has_key("SPLIT"): - delim = xtrans.attr["TABULAR"]["SPLIT"] - str = "" - for s in text.split(delim): - str = str + s - return str; - return text - -# Restore the "canonical" form of the item text by removing any split -# delimiters from it and gluing the resulting parts together. If the -# item has several parts separated by "or" delimiters, only the first -# part is acted upon. -Function: restore_word - if xtrans.attr["TABULAR"].has_key("OR"): - delim = xtrans.attr["TABULAR"]["OR"] - return xtrans.restore_single_word(xtrans.content["ITEM"].split(delim)[0]) - else: - return xtrans.restore_single_word(xtrans.content["ITEM"]) - -# Create a dictionary reference for a given WORD. REFTEXT gives the -# reference text. -Function: dict_reference word, reftext, backref=0 - xtrans.put('<A ') - if backref: - xtrans.put('NAME="id%s" ' % xtrans.dict_encode_string(word)) - xtrans.put('HREF="cgi-bin/dict.cgi?LANG=%s_%s&IDENT=%s">%s</A>' - % (xtrans.attr["LINGUA"]["LANG"], - xtrans.attr["LINGUA"]["TER"], - xtrans.dict_encode_string(word), - reftext)) - -# Return true if we are on the very first data row in a table. Colon -# headings are not counted as data row. -Function: is_first_data_row - if xtrans.attr["TABULAR"].has_key("COLHEADING"): - return xtrans.row_index == 1 - else: - return xtrans.row_index == 0 - -# Return effective row index -# Rows are numbered from 1, column headings are not counted -Function: eff_row_index - if xtrans.attr["TABULAR"].has_key("COLHEADING"): - return xtrans.row_index - else: - return xtrans.row_index + 1 - -# Return effective column (item) index -# Columns are numbered from 1, row headings are not counted -Function: eff_col_index - if xtrans.attr["TABULAR"].has_key("ROWHEADING"): - return xtrans.item_index - else: - return xtrans.item_index + 1 - -Starttag: ENITEM nostrip - xtrans.put('\n<LI>') - -Endtag: ENITEM - xtrans.put('</LI>\n') - -# Map structure: [ start-col, end-col, start-row, end-row, need-ref? ] -Function: parse_dictref str - map = [-1,-1,-1,-1, 0] - for s in str.split(";"): - x = s.split(":") - if x[0] == "col": - n = 0 - elif x[0] == "row": - n = 2 - elif x[0] == "ref": - map[4] = 1 - continue - else: - raise "Unknown modifier " + x[0] - map[n] = int(x[1]) - if len(x) == 3: - map[n+1] = int(x[2]) - else: - map[n+1] = 0 - if map[0] == -1 and map[2] != -1: - map[0] = 1 - map[1] = 1 - elif map[2] == -1 and map[0] != -1: - map[2] = 1 - map[3] = 1 - return map - -Function: need_dictref - if xtrans.attr["TABULAR"].has_key("DICTREF"): - map = xtrans.parse_dictref(xtrans.attr["TABULAR"]["DICTREF"]) - if (map[0] != -1 \ - and (map[0] == 0 or map[0] <= xtrans.eff_col_index()) \ - and (map[1] == 0 or map[1] >= xtrans.eff_col_index()))\ - and (map[2] != -1 \ - and (map[2] == 0 or map[2] <= xtrans.eff_row_index()) \ - and (map[3] == 0 or map[3] >= xtrans.eff_row_index())): - return map[4] + 1 - else: - return 0 - -Function: get_col_align ind - if xtrans.attr["TABULAR"].has_key("COLALIGN"): - s = xtrans.attr["TABULAR"]["COLALIGN"].split(":") - if len(s) == 1: - return xtrans.attr["TABULAR"]["COLALIGN"] - elif len(s) <= ind: - if s[len(s)-1] == "*": - return s[len(s)-2] - else: - return None - elif s[ind] == "*": - return s[ind-1] - elif s[ind] == "": - return None - else: - return s[ind] - else: - return None - -# NOTE: Expansion of quoted tags is performed only for: -# 1) Enumeration items -# 2) Row headings in tables -# 3) Table items, for which no DICTREF is requested -# 4) Page items -Endtag: ITEM - if xtrans.is_parent("ENUMERATE"): - xtrans.put('<LI>') - xtrans.expand_text(xtrans.content["ITEM"]) - xtrans.put('</LI>') - elif xtrans.is_parent("ROW"): - if xtrans.row_index == 0 and xtrans.attr["TABULAR"].has_key("COLHEADING"): - eltname = "TH" - else: - eltname = "TD" - xtrans.put(" <%s" % eltname) - if xtrans.attr["ITEM"].has_key("SPAN"): - if xtrans.attr["ITEM"]["SPAN"] == "0": - n = xtrans.max_items - else: - n = xtrans.attr["ITEM"]["SPAN"] - xtrans.put(' COLSPAN="%s" ALIGN="CENTER"' % n) - else: - if eltname == "TD": - align = xtrans.get_col_align(xtrans.item_index) - if align: - xtrans.put(' ALIGN="%s"' % align) - if xtrans.item_index == 0 and xtrans.attr["ITEM"].has_key("ROWSPAN"): - xtrans.rowspan_end = xtrans.row_index + int(xtrans.attr["ITEM"]["ROWSPAN"]) - xtrans.put(' ROWSPAN="%s"' % xtrans.attr["ITEM"]["ROWSPAN"]) - if xtrans.item_index == 0 and xtrans.attr["TABULAR"].has_key("ROWHEADING"): - xtrans.put(' CLASS="%s"' % xtrans.attr["TABULAR"]["ROWHEADING"]) - xtrans.put(">") - if xtrans.item_index == 0 and xtrans.attr["TABULAR"].has_key("ROWHEADING"): - xtrans.expand_text(xtrans.content["ITEM"]) - else: - x = xtrans.need_dictref() - if x: - xtrans.dict_reference(xtrans.restore_word(), - xtrans.item_text(), x) - else: - xtrans.expand_text(xtrans.item_text()) - xtrans.put("</%s>" % eltname) - xtrans.item_index = xtrans.item_index + 1 - if xtrans.max_items < xtrans.item_index: - xtrans.max_items = xtrans.item_index - elif xtrans.is_parent("GROUP"): - xtrans.menu_append_function(xtrans.content["ITEM"]) - elif xtrans.is_parent("PAGE"): - xtrans.put('<H2>') - xtrans.expand_text(xtrans.content["ITEM"]) - xtrans.put('</H2>') - else: - xtrans.put('<DD>') - xtrans.expand_text(xtrans.content["ITEM"]) - xtrans.put('</DD>') - -Endtag: FLECT - if xtrans.attr["FLECT"].has_key("SPLIT"): - str = "" - for s in xtrans.content["FLECT"].split(xtrans.attr["FLECT"]["SPLIT"]): - if str == "" : - str = "-" + s - else: - str = str + " " + ", -" + s - - xtrans.put('<B>%s</B>' % str) - else: - xtrans.put('<B>-%s</B>' % (xtrans.content["FLECT"])) - -Endtag: PREF - xtrans.put('<B>%s</B>' % (xtrans.content["PREF"])) - -Endtag: SUFF - xtrans.put('<B>%s</B>' % (xtrans.content["SUFF"])) - -Endtag: DICTREF - xtrans.dict_reference(xtrans.content["DICTREF"], - xtrans.content["DICTREF"]) - -#Starttag: MENU -# xtrans.menu[xtrans.attr["MENU"]["NAME"]] = [] - -Starttag: ENUMERATE - if xtrans.is_parent("PARA"): - xtrans.attr["PARA"]["__CLOSED__"] = 1 - xtrans.put("\n</P>\n") - xtrans.put('<UL>\n') - -Endtag: ENUMERATE - xtrans.put('</UL>\n') - -Endtag: EMPH nostrip - xtrans.put("""<B>%s</B>""" % (xtrans.content["EMPH"])) - -Endtag: SUBSCRIPT nostrip - xtrans.put("""<sub>%s</sub>""" % (xtrans.content["SUBSCRIPT"])) - -Endtag: DFN nostrip - xtrans.put("""<DFN>%s</DFN>""" % (xtrans.content["DFN"])) - -Endtag: IT nostrip - xtrans.put('<I>%s</I>' % (xtrans.content["IT"])) - -Function: alignment align - if align == "": - xtrans.put('</DIV>\n') - else: - xtrans.put('<DIV ALIGN="%s">' % (align)) - - -Starttag: TABULAR - if xtrans.is_parent("PARA"): - xtrans.attr["PARA"]["__CLOSED__"] = 1 - xtrans.put("\n</P>\n") - if xtrans.attr["TABULAR"].has_key("SPACE"): - for i in range(int(xtrans.attr["TABULAR"]["SPACE"])): - xtrans.put('<BR>') - if xtrans.attr["TABULAR"].has_key("ALIGN"): - if xtrans.attr["TABULAR"]["ALIGN"] != "NONE": - xtrans.alignment(xtrans.attr["TABULAR"]["ALIGN"]) - else: - xtrans.alignment("CENTER") - xtrans.put('<TABLE CELLPADDING="10%" ') - if xtrans.attr["TABULAR"].has_key("TYPE"): - if xtrans.attr["TABULAR"]["TYPE"] == "EXAMPLE": - xtrans.attr["TABULAR"]["NOFRAME"] = 1 - if not xtrans.attr["TABULAR"].has_key("NOFRAME"): - xtrans.put(' frame="box"') - if not xtrans.attr["TABULAR"].has_key("BESTFIT"): - xtrans.put(' WIDTH="95%"') - if xtrans.attr["TABULAR"].has_key("CLASS"): - xtrans.put(' class="%s"' % (xtrans.attr["TABULAR"]["CLASS"])) - xtrans.put(">\n") - if xtrans.attr["TABULAR"].has_key("TYPE"): - if xtrans.attr["TABULAR"]["TYPE"] == "EXAMPLE": - xtrans.put('<COL SPAN=2 WIDTH="50%">\n') - xtrans.row_index = 0 - xtrans.max_items = 0 - xtrans.separator_row = 0 - -Endtag: TABULAR - xtrans.put("</TABLE>\n") - if not xtrans.attr["TABULAR"].has_key("ALIGN") \ - or xtrans.attr["TABULAR"]["ALIGN"] != "NONE": - xtrans.alignment("") - if xtrans.attr["TABULAR"].has_key("AFTERSPACE"): - for i in range(int(xtrans.attr["TABULAR"]["AFTERSPACE"])): - xtrans.put('<BR>') - -Starttag: ROW - xtrans.item_index = 0 - if xtrans.row_index == 0 and xtrans.attr["TABULAR"].has_key("COLHEADING"): - xtrans.put('<THEAD class="%s">' % xtrans.attr["TABULAR"]["COLHEADING"]); - xtrans.put("<TR>\n") - else: - xtrans.put("<TR") - if xtrans.attr["TABULAR"].has_key("ALTERNATE"): - if (xtrans.row_index - xtrans.separator_row) % 2 == 0: - xtrans.put(' class="even"') - else: - xtrans.put(' class="odd"') - xtrans.put(">\n") - if xtrans.row_index < xtrans.rowspan_end: - xtrans.item_index = xtrans.item_index + 1 - -Endtag: ROW - xtrans.put("</TR>") - if xtrans.row_index == 0 and xtrans.attr["TABULAR"].has_key("COLHEADING"): - xtrans.put("</THEAD>"); - xtrans.put("\n") - xtrans.row_index = xtrans.row_index + 1 - if xtrans.row_index == xtrans.rowspan_end: - xtrans.rowspan_end = 0 - - -Starttag: SEPARATOR - if xtrans.attr["SEPARATOR"].has_key("SPAN"): - max_items = int(xtrans.attr["SEPARATOR"]["SPAN"]) - else: - max_items = xtrans.max_items - xtrans.put('\n<TR><TD COLSPAN="%d" class="separator">' % max_items) - -Endtag: SEPARATOR - xtrans.put('</TD></TR>\n') - if xtrans.attr["SEPARATOR"].has_key("INITCOUNT") or xtrans.attr["TABULAR"].has_key("INITCOUNT"): - xtrans.separator_row = 0 - else: - xtrans.separator_row = xtrans.row_index - - -Function: class_begin attr, class_name - if xtrans.is_parent("ROW"): - tag = "TD" - elif xtrans.is_parent("TABULAR"): - xtrans.put('<TR class="%s">' % (class_name)) - tag = "TD" - elif attr.has_key("TYPE"): - if attr["TYPE"] == "INLINE": - tag = "SPAN" - else: - tag = "DIV" - elif attr.has_key("ALIGN"): - tag = "DIV ALIGN=\"" + attr["ALIGN"] + "\"" - else: - tag = "SPAN" - xtrans.put('<%s class="%s">' % (tag, class_name)) - -Function: class_end attr - if xtrans.is_parent("ROW"): - tag = "TD" - elif xtrans.is_parent("TABULAR"): - tag = "TD" - elif attr.has_key("TYPE"): - if attr["TYPE"] == "INLINE": - tag = "SPAN" - else: - tag = "DIV" - elif attr.has_key("ALIGN"): - tag = "DIV" - else: - tag = "SPAN" - xtrans.put('</%s>' % tag) - if xtrans.is_parent("TABULAR"): - xtrans.put('</TR>') - -Starttag: EXAMPLE nostrip - xtrans.class_begin(xtrans.attr["EXAMPLE"], "example") - -Endtag: EXAMPLE - xtrans.class_end(xtrans.attr["EXAMPLE"]) - -Starttag: TRANS nostrip - xtrans.class_begin(xtrans.attr["TRANS"], "translation") - -Endtag: TRANS - xtrans.class_end(xtrans.attr["TRANS"]) - -Starttag: SAMP - xtrans.put('<SPAN class="sample">') - -Endtag: SAMP - xtrans.put('</SPAN>') - -Endtag: NOTREADY - xtrans.put("""<table class="notready"> -<tr> -<td><img border="0" src="graphics/construction.jpg" alt="[ Construction Bar ]" width="300" height="28"></img></td> -<td class="notready">%s</td> -<td><img border="0" src="graphics/construction.jpg" alt="[ Construction Bar ]" width="300" height="28"></img></td> -</table>""" % (xtrans.content["NOTREADY"])) - -Starttag: LOCALIZATION - pass - -Endtag: MSGSTR - xtrans.msgid(xtrans.attr["MSGSTR"]["ID"], xtrans.content["MSGSTR"]) - - -Function: prefix ref - if ref[0] == '/': - return ref[1:] - elif xtrans.attr["LINGUA"].has_key("TARGETDIR"): - return xtrans.attr["LINGUA"]["TARGETDIR"] + "/" + ref - else: - return xtrans.environ['TARGET_DIR'] + "/" + ref - return ref - -Function: put_menu_item cur, ref, label, level=0 - xtrans.put('<TR><TD>') - if level > 0: - for i in range(level-1): - xtrans.put('>') - if cur: - xtrans.expand_text(label) - else: - xtrans.put('<A HREF="%s">' % xtrans.prefix(ref)) - xtrans.expand_text(label) - xtrans.put('</A>') - xtrans.put('</TD></TR>\n') - - -Function: is_cur menu_item, fileno - if fileno == -1: - return 0 - else: - return menu_item[1] == xtrans.filenames[fileno] - -Function: is_cur_menu menu, fileno - for i in range(len(menu)): - if menu[i][0] == 0: - if xtrans.is_cur(menu[i], fileno): - return 1 - elif menu[i][0] == 1: - if xtrans.is_cur_menu(menu[i][1], fileno): - return 1 - return 0 - - -Function: out_menu menu, fileno=-1, cutlevel=-1, level=0, start=0 - for i in range(start,len(menu)): - if menu[i][0] == 0: - xtrans.put_menu_item(xtrans.is_cur(menu[i], fileno), menu[i][1], menu[i][2], level) - elif menu[i][0] == 1: - if cutlevel == -1 or level < cutlevel: - if menu[i][2] != "": - xtrans.put('<TR><TD class="group"><DIV ALIGN="CENTER">%s</DIV></TD></TR>\n' % menu[i][2]) - xtrans.out_menu(menu[i][1], fileno, cutlevel, level+1) - elif level == cutlevel: - if menu[i][2] == "" and menu[i][1][0][0] == 0: - xtrans.put_menu_item(xtrans.is_cur(menu[i][1][0], fileno), - menu[i][1][0][1], menu[i][1][0][2], - level) - if xtrans.is_cur_menu(menu[i][1], fileno): - xtrans.out_menu(menu[i][1], fileno, cutlevel+1, - level+1, 1) - elif menu[i][0] == 2: - xtrans.attr["LINGUA"][menu[i][1]](fileno) - else: - raise "Unknown menu item " + menu[i][0] - - -# Debugging call -Function: p_menu menu - for i in range(len(menu)): - item = menu[i] - print("IND ", i, "TAG ", item[0], "IT ", item[1], "TW", item[2]) - if item[0] == 0: - print("ITEM" , item[1]) - elif item[0] == 1: - print("SUB", item[1]) - xtrans.p_menu(item[1]) - else: - print("MALFORMED MENU") - -Postmacro: TOC - menu = xtrans.attr["LINGUA"]["MENU"] - xtrans.out_menu(menu, currentfileno, 1) - - -Function: menu_map menu, start=0 - xtrans.put('<UL>') - for i in range(start,len(menu)): - if menu[i][0] == 0: - xtrans.put('<LI><A HREF="%s">' % (xtrans.prefix(menu[i][1]))) - xtrans.expand_text(menu[i][2]) - xtrans.put('</A></LI>\n') - elif menu[i][0] == 1: - if menu[i][2] != "": - xtrans.put('<LI>') - xtrans.expand_text(menu[i][2]) - xtrans.menu_map(menu[i][1]) - xtrans.put('</LI>') - else: - submenu = menu[i][1] - xtrans.put('<LI><A HREF="%s">' % (xtrans.prefix(submenu[0][1]))) - xtrans.expand_text(submenu[0][2]) - xtrans.put('</A>\n') - xtrans.menu_map(submenu, 1) - xtrans.put('\n</LI>\n') - else: - pass - xtrans.put('</UL>') - -Postmacro: SITEMAP - menu = xtrans.attr["LINGUA"]["MENU"] - xtrans.menu_map(menu) - -Endtag: BOTTOM - xtrans.attr["PAGE"]["BOTTOM"] = xtrans.content["BOTTOM"] diff --git a/xtrans/Makefile.am b/xtrans/Makefile.am deleted file mode 100644 index e58c9f2..0000000 --- a/xtrans/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST=LINGUA.html.xtrans i18n.inc
\ No newline at end of file diff --git a/xtrans/i18n.inc b/xtrans/i18n.inc deleted file mode 100644 index 5472368..0000000 --- a/xtrans/i18n.inc +++ /dev/null @@ -1,48 +0,0 @@ -# -*- mode: indented-text -*- -# This file is part of GNU RADIUS documentation. -# Copyright (C) 2000,2001,2002 Sergey Poznyakoff -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -Global: linguas -[ 'en', 'fr', 'pl', 'es', 'el', 'ru' ] - - -Function: translations - if not xtrans.attr["LINGUA"].has_key("GETTEXT"): - xtrans.attr["LINGUA"]["GETTEXT"] = {} - return xtrans.attr["LINGUA"]["GETTEXT"] - -Function: msgid id, str - xtrans.translations()[id] = str - -Function: SetLocale lang - xtrans.lang = lang - -Function: gettext messid - translations = xtrans.translations() - if not translations.has_key(messid): - return messid - return translations[messid] - -Global: charset_dict -{ 'def' : "iso-8859-1", 'pl': "iso-8859-2", 'ru': "koi8-r" } - -Function: charset lang - if not xtrans.charset_dict.has_key(lang): - lang = 'def' - return xtrans.charset_dict[lang] - - |