When Magnus told me that there are only 100 lines of code abstracted to support English, I thought that it is something to share with you. What can you do with these 100 lines to support *YOUR* language?
Thanks,
GerardM
NOTE this is incomplete, but most of it. abstraction will continue.
Full code is here:
// ENGLISH
language_specs['en'] = new lang_class ;
language_specs['en'].employers = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' worked for ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep+(num+1<d.length?'for ':'') } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].position = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' was'+(is_dead?'':'/is')+' ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
// qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].member = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' was'+(is_dead?'':'/is')+' a member of ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
// qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].alma = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' studied at ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].field = function ( d ) { this.simpleList ( d , his_er+' field of work include'+(is_dead?'d':'s')+' ' , '. ' ) ; }
language_specs['en'].cause_of_ death = function ( d ) { this.simpleList ( d , 'of ' , ' ' ) ; }
language_specs['en'].killer = function ( d ) { this.simpleList ( d , 'by ' , ' ' ) ; }
language_specs['en'].sig_event = function ( d ) { this.simpleList ( d , s_he+' played a role in ' , '.' ) ; }
language_specs['en'].spouses = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' married ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { cb(); h.push ( { label:' ' } ) ; } ,
date_to : function(cb) { h.push ( { label:'(married until ' } ) ; cb() ; h.push ( { label:') ' } ) } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].children = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:his_er+' children include ' } ) } ,
item_start : function(cb) { cb() } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en']. firstSentence = function () {
h.push ( { label:$('#main_title_label'). text() , before:'<b>' , after:'</b> ' } ) ;
h.push ( { label:(is_dead?'was':'is') , after:' a ' } ) ;
this.listNationalities() ;
this.listOccupations() ;
h.push ( { label:'. ' } ) ;
if ( h.length == 3 ) h = [] ; // No information, skip it.
}
language_specs['en'] = new lang_class ;
language_specs['en'].employers = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' worked for ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep+(num+1<d.length?'for ':'') } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].position = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' was'+(is_dead?'':'/is')+' ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
// qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].member = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' was'+(is_dead?'':'/is')+' a member of ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
// qualifiers : { job:function(qv){h.push ( { before:'as ' , q:qv[0] , after:' ' } )} } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].alma = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' studied at ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { h.push ( { label:'from ' } ) ; cb({no_prefix:true}) } ,
date_to : function(cb) { h.push ( { label:'until ' } ) ; cb({no_prefix:true}) } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].field = function ( d ) { this.simpleList ( d , his_er+' field of work include'+(is_dead?'d':'s')+' ' , '. ' ) ; }
language_specs['en'].cause_of_
language_specs['en'].killer = function ( d ) { this.simpleList ( d , 'by ' , ' ' ) ; }
language_specs['en'].sig_event = function ( d ) { this.simpleList ( d , s_he+' played a role in ' , '.' ) ; }
language_specs['en'].spouses = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:s_he+' married ' } ) } ,
item_start : function(cb) { cb(); h.push ( { label:' ' } ) } ,
date_from : function(cb) { cb(); h.push ( { label:' ' } ) ; } ,
date_to : function(cb) { h.push ( { label:'(married until ' } ) ; cb() ; h.push ( { label:') ' } ) } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].children = function ( d ) {
this.listSentence ( {
data : d ,
start : function() { h.push ( { label:his_er+' children include ' } ) } ,
item_start : function(cb) { cb() } ,
item_end : function(num,sep) { h.push ( { label:sep } ) } ,
end : function() { h.push ( { label:'. ' } ) }
} ) ;
}
language_specs['en'].
h.push ( { label:$('#main_title_label').
h.push ( { label:(is_dead?'was':'is') , after:' a ' } ) ;
this.listNationalities() ;
this.listOccupations() ;
h.push ( { label:'. ' } ) ;
if ( h.length == 3 ) h = [] ; // No information, skip it.
}
1 comment:
nice blog.
Post a Comment