From Braniecki's Wiki
Revision as of 15:47, 27 July 2008 by Zbraniecki (talk | contribs)
Jump to navigation Jump to search

Silme is built around several abstract concepts that allow the library to support any possible localization format, from DTD, GetText or XLIFF, to MySQL and SQLite, from JAR and normal directory to SVN, CVS or any other Revision Control System. In this section I will explain the basic concepts that will allow you to understand the architecture of the library.


Silme's most core and atom unit is Entity. Entity is a class that stores single pair of ID<-->VALUE in an abstract model. It is a representation of DTD's


, Gettext's

msgid "ID"\nmsgstr "VALUE"

, MySQL's ID column and VALUE column in L10n table etc., etc...

It's very important to understand that you can serialize any localization list to use Entity as long as you can generate unique ID across one list and assign it a value.

Group of Entity objects is stored as a EntityList object. EntityList is a list (in fact, a dict structure in Python) that stores list of Entities and nothing more. The easiest way to imagine it is a localization SQL table containing two columns - ID and VALUE. The single row is Entity, the whole table is EntityList.

Above that, in some abstract sense, there is L10nObject class. L10nObject extends EntityList and is a representation of any L10n file. So beside of list of Entity objects it also contains Comment objects and normal Strings between them. It's easiest to imagine it as a full representation of simple DTD file:

<!ENTITY myapp.title "MyApp Title">
Not used anymore
<!ENTITY title.old "Some Title">
<!ENTITY notify.msg "Please, click OK to continue">
<!ENTITY notify.btn "OK">

will look like this:

Entity(id:'myapp.title',value:'MyApp Title')
  String('\nNot used anymore\n')
  Entity(id:'title.old', value:'Some Title')
Entity(id:'notify.msg',value:'Please, click OK to continue')