Closed nodecode closed 10 years ago
BTW: The replace of normal variables like myVar
is also not supported yet, right? That would be also a useful feature.
Hum… I don't understand. We currently do support filters with a key and an object of options/variables.
The translation in the namespace "my_ns":
"greetings": "Hello __username__!"
$scope.user = {name: 'Etienne'};
var res = $filter('i18next')('greetings', {ns: 'my_ns', username: $scope.user.name});
// res === "Hello Etienne!"
<p>{{'greetings' |i18next:{ns: 'my_ns', username: $scope.user.name}}}</p>
<p>{{'my_ns:greetings' |i18next:{username: $scope.user.name}}}</p>
<p ng-i18next="[i18next]({username: $scope.user.name})my_ns:greetings" />
<p ng-i18next>[i18next]({username: $scope.user.name})my_ns:greetings</p>
BTW, whereas we can do this with the filter syntax, using ng-i18next directives instead is better because they are:
I especially like and use the last format I gave in the example above (and you can indent if you like.
For example:
<p ng-i18next>
[i18next]({
username: $scope.user.name,
gender: $scope.user.gender,
role: '<span class="role">(' + $scope.user.role + ')</span>'
})my_ns:greetings
</p>
Ah ok, I thought that ng-i18next not support such a thing, because I have nowhere found a corresponding example. Then my request has completed. Thanks!
It would be great if you could pass sprintf parameters also to the i18next filter.
I am thinking of a similar implementation as in angular-translate. Here you transmitted to the filter parameters as follows:
Such an implementation in ng-i18next would be very helpful for my current project. Thank you in advance!