Difference between revisions of "Internationalization/code parser"

m (Reading and parsing)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Summary ==
+
[[Category:Internationalization]]
That's what this part of the project should achieve:
+
[[Category:Internationalization SA project]]
* reading and parsing of MO files containing the strings and their translations
+
* organize the object collection in an incremental way: don't load the whole file if it's not needed
+
* give a simple interface to the localization class, so that the strings can be printed out without too much efforts
+
  
== Reading and parsing ==
+
==Code Parser==
  
=== Parser structure ===
+
This part of the project should produce a clickable thing in EiffelStudio.
  
I'll propose the class structure of the parser, later.
+
When actually clicked, it should examine the current project. If the current project includes our wonderful framework, this clicky thing should look at the calls to the i18n and i18n_plural functions and produce a .po file based on the strings provided to those functions as arguments.
  
=== MO file structure ===
+
===Composition===
  
As reported from the gettext manual.
+
There are several things needed:
  
          byte
+
* The clicky thing itself.
                +------------------------------------------+
+
* An ast visitor that finds calls to i18n and i18n_parser and then extracts arguments.
            0  | magic number = 0x950412de                |
+
* A set of classes that provides a nice representation of a .po file.
                |                                          |
+
* A GUI to ask where to place the .po file and if the project should first be recompiled.
            4  | file format revision = 0                |
+
 
                |                                          |
+
===Progress===
            8  | number of strings                        |  == N
+
 
                |                                          |
+
<strike>First commit Real Soon Now&trade;</strike> Initial commit made.
            12  | offset of table with original strings    |  == O
+
 
                |                                          |
+
Status is currently (16:24, 1 July 2006 (CEST)):
            16  | offset of table with translation strings |  == T
+
 
                |                                          |
+
* Clicky thing: <font color="orange">Mostly works. Some bugs related to escaping that need fixing.</font>
            20  | size of hashing table                    |  == S
+
* AST visitor: <font color="green">No apparent bugs</font>
                |                                          |
+
* .po representation: <font color="orange">Works. Needs word wrapping for long entries.</font>
            24  | offset of hashing table                  |  == H
+
* GUI: <font color="green">Works</font>
                |                                          |
+
                .                                          .
+
                .    (possibly more entries later)        .
+
                .                                          .
+
                |                                          |
+
            O  | length & offset 0th string  ----------------.
+
        O + 8  | length & offset 1st string  ------------------.
+
                ...                                    ...  | |
+
O + ((N-1)*8) | length & offset (N-1)th string          |  | |
+
                |                                          |  | |
+
            T  | length & offset 0th translation  ---------------.
+
        T + 8  | length & offset 1st translation  -----------------.
+
                ...                                    ...  | | | |
+
T + ((N-1)*8) | length & offset (N-1)th translation      |  | | | |
+
                |                                          |  | | | |
+
            H  | start hash table                        |  | | | |
+
                ...                                    ...  | | | |
+
    H + S * 4  | end hash table                          |  | | | |
+
                |                                          |  | | | |
+
                | NUL terminated 0th string <----------------' | | |
+
                |                                          |    | | |
+
                | NUL terminated 1st string  <------------------' | |
+
                |                                          |      | |
+
                ...                                   ...      | |
+
                |                                          |      | |
+
                | NUL terminated 0th translation  <---------------' |
+
                |                                          |        |
+
                | NUL terminated 1st translation  <-----------------'
+
                |                                          |
+
                ...                                    ...
+
                |                                          |
+
                +------------------------------------------+
+

Latest revision as of 08:31, 15 August 2006


Code Parser

This part of the project should produce a clickable thing in EiffelStudio.

When actually clicked, it should examine the current project. If the current project includes our wonderful framework, this clicky thing should look at the calls to the i18n and i18n_plural functions and produce a .po file based on the strings provided to those functions as arguments.

Composition

There are several things needed:

  • The clicky thing itself.
  • An ast visitor that finds calls to i18n and i18n_parser and then extracts arguments.
  • A set of classes that provides a nice representation of a .po file.
  • A GUI to ask where to place the .po file and if the project should first be recompiled.

Progress

First commit Real Soon Now™ Initial commit made.

Status is currently (16:24, 1 July 2006 (CEST)):

  • Clicky thing: Mostly works. Some bugs related to escaping that need fixing.
  • AST visitor: No apparent bugs
  • .po representation: Works. Needs word wrapping for long entries.
  • GUI: Works