tinganho / l10ns

Internationalization workflow and formatting
http://l10ns.org
Apache License 2.0
234 stars 24 forks source link

Design - Compiled output size #123

Closed bbenezech closed 8 years ago

bbenezech commented 8 years ago

Hi @tinganho

I just reviewed I10ns for my needs, I love it and I considered using it until I realized that the compiled translation function was huge for each key, and makes it a deal-breaker for client-side projects with many translations.

Have you considered not pre-compiling the json and use it directly at runtime?

tinganho commented 8 years ago

@bbenezech I try to keep it as compact as possible. for example a string with no complex translation (i.e. pluralization, date formatting etc.). It is just a string getter.

function () {
   var str = '';
   str += 'hello world';
   return str;
}

It can however store some localization data on the output, that can be rather large. Though it would be large even if you only used JSON. Some way or another the localization data must be there :wink:.

For perf reasons I would not use the JSON directly. It compiles the MessageFormat strings and I wouldn't during runtime wan't to parse the MessageFormat strings. That would be a perf hit.

I recommend to use all.js file in your server. And all individual language files en-US.js etc if you are on a client.