-
Notifications
You must be signed in to change notification settings - Fork 154
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
Clarify that gettext() only serves for extraction #20
Comments
I think changing the example here would help: http://angular-gettext.rocketeer.be/dev-guide/annotate-js/ It would be useful to include an example of displaying a string which is extracted from JS. To modify your current example slightly... Controller: angular.module("myApp").controller("helloController", function ($scope, UserService, gettext) {
$scope.greeting = gettext("Hello");
$scope.username = UserService.getName();
}); View: <div ng-controller="helloController">
<h1>{{ greeting | translate }}, {{username}}</h1>
</div> |
Well, the example you're proposing could be written as But I totally agree, we need a good example. I typically run into these when generating mark-up (e.g. a list of translated menu items generated with |
I was also confused by this, and looking for more info. Maybe it is just the interface being counterintuitive? Maybe having |
Use |
I knew that, but i argue that the behaviour many expect and the related use case should not be considered probably wrong
This is mostly true, but if someone is digging into "translating directly in javascript" probably the |
Except it is. To do translations properly means doing it in the views. Note that nothing is impossible with the current design, it simply encourages the proper usage. You should take this as a general guideline: the easiest path is probably the best one. The only exception where translating directly in JS is desired is as you mention: interop with other libraries. It's perfectly possible to do that, it's just not the easiest and most obvious way, but that's because in most cases it's not the thing you need anyway. |
This comes up again and again:
The text was updated successfully, but these errors were encountered: