Closed boustanihani closed 9 years ago
There is a method Translator#isLoading() which you could use for that.
<body>
{{#unless isLoading}}
{{> yield}}
{{/unless}}
</body>
UI.body.helpers({
isLoading: function () {
return FrontLang.isLoading()
}
});
However that isn't a very nice solution imo. I could just return empty strings as long as the namespace is loading, what do you think?
Mmmh empty strings is better than keys I think :) but I preffer a way (kind of a global hook maybe) preventing any template from rendered (or setting it invisible) if it needs translations which still have not been loaded .. this would be perfect, I preffer to see nothing much more than seeing a form with visible input fields and missing labels!
I think this package should hook into the blaze-rendering-engine to achieve that, sadly I am a meteor beginner, but I would have loved to help extending your awesome work :)
The translator now returns null when the translation isn't loaded yet. Blaze is intelligent enough to convert null into nothing in the template and it seems more clean than an empty string (although i thought about returning undefined).
I currently shy away from hooking into blaze mostly because:
<script>
into the html with the autodetected language in src. That way the browser could load it way earlier. This however also requires #3 to be done so nothing unneeded is loaded.
I noticed that the translation keys are rendered shortly before the translation occurs. This is really a matter of milliseconds (200ms - 400ms) but it doesn't look nice :(
There should be some way to prevent the templates from being rendered before the translation-data is fully loaded!!