-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove use of $translate in ImportKml directive #185
Conversation
Remove use of $translate in ImportKml directive
// We use $compile only for the translation, | ||
// $translate("drop_me_here") didn't work in prod mode | ||
$compile(dropZone)(scope); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know the reason why it didn't work in prod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gjn. Wanted to ask the same. It doesn't make sense. And it may actually hide a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I didn't find why. I thought it was a goog.require missing or something like that but no. And when I 've tried to debug the code with the chrome debugger it works, maybe a loading problem of json files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Differences between prod and src are usually big smells. If it was a silent failure (without any error in the console), it could mean that $translate is known but not yet initialized with the translations the moment it's called.
Seems like a timing/async issue to me. We probably were just lucky in src mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I correct what I've said:
In prod mode that never works
In dev mode if you clear the cache, sometimes it works sometimes no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it makes more sense. Probably related to the asynchronous loading of translation files, as @gjn said it. We should look at the problem more closely, to understand when it triggers, otherwise we'll fall into the trap again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm, when you clear the cache the async requests, which load the json files, finish after the link function is executed.
I've added an issue: #198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $compile is needed whenever there is angular bindings inside the html snippet. So having $compile makes sense.
<div>' + $translate('drop_me_here') + '</div>
would not react to language changes.
Edit: I know see why <div>' + $translate('drop_me_here') + '</div>
worked. It's calling the function directly, and it was not part of the html snipped.
In prod the label was not translated, with $compile it works