L20n/Features/Variable watching

From MozillaWiki
< L20n‎ | Features
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


goal

Watch for changes of value of context variables and globals and update the localization automatically when the changes occur.

example

   <timeOfDay() { @hour <= 12 ? "morning" : @hour <= 18 ? "afternoon" : "evening" }>                      
                                                                                                          
   <greeting[timeOfDay()] {                                                                               
     morning: "Good morning, {{ $user.firstname }}!",                                               
     afternoon: "Good afternoon, {{ $user.firstname }}!",                                           
     evening: "Good evening, {{ $user.firstname }}!"                                                
   }>


When the value of @hour changes, we should be able to automatically update the translation. We'd need some kind of a watcher/observer pattern in l20n.

Might want to look into JavaScript's watch (non-standard, not recommended) or the corresponding polyfill.

status

not in 1.0