[Rails] [ANN] Internationalization Library: MLL

F. Egger f.egger.mailings at digitpaint.nl
Mon Jan 31 22:34:34 GMT 2005


The harvester actually always uses a lexer, wether it's for ruby code or 
for html/xml. When "harvesting" ruby code, it looks for a token of group 
string that is preceded by the right identification token. When you 
actually run the code with _("") in it, the method Object._(str) (or 
when you are running it from rails: ActionController::Base._(str) ) is 
called, which does the localization.

The harvester (and the localizer) for the templates actually uses the 
Syntax lexer, (also used in Hieraki, if i'm not mistaken). The lexer 
decides wether something is an element "text" node. This is why the 
localization process is currently only working in "cache mode": the 
lexer is relatively slow. Once a template is cached, this should be just 
as fast as regular templates.

Also the cache-templating is designed that it should not break any Rails 
specific caching mechanisms. This is not tested yet tough.

The strings are stored in a YML file, as a hash with a MD5 hash of the 
original string as the key.


Carl Youngblood wrote:

> F. Egger wrote:
>
>> * Can do template translations before they are rendered without
>>    having to encapsulate all strings with <%= _("string") %>. This 
>> template translation however
>>    has to be done through some kind of cache. 
>
>
> This sounds really great.  So I'm just curious as to how the harvester 
> determines where a string ends and begins.  Does it just look 
> in-between the tags?  Also, forgive me since I'm not too familiar with 
> gettext (I actually helped develop a home-grown system that did much 
> the same thing), but does this basically collect all the strings that 
> are inside the _() and store them in a document for translation?  What 
> file format are the strings stored in?  Are static locale-specific 
> files generated to make it faster, or are they retrieved from a 
> file/db every time?
>
> Thanks,
> Carl
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails




More information about the Rails mailing list