Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd a support for ngCloak \ prevent keys appearing on first page load #237
Comments
|
This happens because the Ideas? |
|
@BeOleg @frapontillo Its just a logical behaviour. When using an asynchronous loader and not providing a default language statically (by adding it via To get around this, you have to provide at least one language statically, preferably its the default language (the one you configure with Here are some resources: Events: http://pascalprecht.github.io/angular-translate/docs/en/#/guide/16_events hope this helps. |
|
So can I provide a static subset of basic defaults of a language (e.g. 'en-US'), that will then be overridden by, for example, |
|
@frapontillo unfortunately you cannot set a subset of translations when using staticFilesLoader. If you want to add translations statically, you have to add a whole language, so a complete translation table. Because, when using the asynchronous loader, What you want is the partialLoader. You can actually do exactly that with the partialLoader. Unfortunately there's a little bug, which is fixed in |
|
@frapontillo Landed yesterday in |
|
Great, thanks! |
|
Just out of curiosity, why not an option in the provider allowing for the directive to hide content until the asynchronous call to get translations returns? |
|
@devorbitus Could you please be a bit more concrete :) ? Pseudo example? Just to make sure I'll answer with the right arguments. |
|
In my case I just monkey patched the finished angular-translate.js file to add the following if statement just inside the link function of the translate directive...
Then I placed the translate-hide-until attribute on the element I wanted hidden and it remained hidden until translations arrived. The correct way to do this at a project level would be to add an option to the provider but I only had a couple items in my header that were FOUC. |
|
To me, this just makes more sense than having to include a default language. Especially on a finished product that might be white labeled for different languages for different customers. You wouldn't want your German only customer to be forced to see a flash of English. |
|
@devorbitus I agree that we need another/a better solution for that, but I'm not sure if it's a good thing to show/hide on each element that has translate directive. |
|
Yeah, I am in now way advocating for this to be the default behaviour just an option. |
|
+1 |
1 similar comment
|
+1 |
|
I'm using the Url Loader, so when the server response is slow it shows the i18n keys.. not very nice ;) |
|
@IpsBetty i'm on it. |
|
@PascalPrecht sehr cool! |
|
Great @PascalPrecht ! |
|
+1 |
|
Hi @PascalPrecht! We are looking to use the feature in our product but this FOUC thing makes us put internationalization on hold. Is there a workaround that would help to pre-load selected (e.g. German) translation table synchronously? Thanks. BTW, the framework is great! |
|
@avmolchanov Well I think the only thing you can do is to ship your app with at least one language and make that language the preferred language. |
|
Actually i'm working on a 2.0 release and want to address all issues there, but it seems like it'll take to much time. So i'll probably cherry pick some already implemented features and do some minor releases. |
|
Great, thanks! |
|
@avmolchanov you can still rely on the |
Actually, you can deal with this on your own. You introduce a scope expression defining whether translation (or even other i18n stuff) is already loaded or not. Unless it is loaded, you will show something like a splashscreen, a styled "blank" screen or whatever. The only have to is more or less the page title, which can be handled either with an own dedicated "setPageTitle" using the So, in a nutshell: $rootScope.i18nLoaded = false;
$rootScope.$on('translateChangeSuccess', function () {
$rootScope.i18nLoaded = true;
});<body>
<main ng-show="i18nLoaded">Loading...</main>
<main ng-hide="i18nLoaded">>ourapp</main>
</body>Using a pseudo language would be:
Actually, you should have already that kind of mechanisms or how you deal with user sessions and session located locales? |
|
Implemented in |
On the first load of the page the phrase keys appear for several instances instead of the translated values.
tried using ng-bind-template, but no luck, the problem is because I am only getting the user's language by an ajax request.
And setting the wrong language by default is as much bad as showing the phrase keys.
Any thoughts?