So far I'm using Globalize for i18n and l10n of my JavaScript apps (built with jQuery UI). This works, but it ties my code to another specific library. Now I'm looking for a way to overcome this issue because I reuse some source that does not support i18n right now and I would rather not change this. I'm not talking about using a global interface for i18n where I could plug in any implementation. To summarize: How do I add i18n and l10n support to existing applications without changing it's source? I'm not asking if this is a good idea, I'm asking if this is possible and how.
So far I've come up with these approaches, but both have their flaws:
If I'd rely on the use of jQuery (which I could in my case), I could replace the text/val/append etc. methods, i.e. all that manipulate the DOM. But there are quite many of these, of which everyone behaves a little different. I could also take this a step further and replace the DOM methods.
Walk the DOM and replace text nodes and form values. This would work, but it is expensive and dynamic changes are hard to detect since there is no standardized way to do it.
Those provide a partial solution to the i18n problem, but for l10n neither of this may work.
How would you approach the problem of adding i18n and l10n support to existing apps?