angular-translate

Chaining Angular promise rejections

笑着哭i 提交于 2019-12-02 11:55:31
I have a chained promise and in the case of a rejection for either of the promises, I need to perform an async operation (get the translated error message). As I've already got a chained promise on success, I assume it's not possible to also chain on rejection - I am attempting to simply nest the async calls, but I'm not getting the resolved promise back from deferred.reject(deferredRejection.promise); below. Pointers appreciated! login: function(email, password) { var deferred = $q.defer(); AuthService.login(email, password).then(function(response) { var user = { 'accountToken': response

angular-translate ad ng-options

戏子无情 提交于 2019-12-01 03:55:21
I'm trying to translate a select drop-down and I don't like the way I'm doing it, because it's cumbersome and it bypasses the whole angular-translate framework. The locale data looks like {"lang": {"label": "text", "select": {"k1": "var1", "k2": "var2"}}} and if I plonk the "select" member in the controller scope, I can write something like "k as v for (k,v) in scopedvar" in the ng-options of the select. Basically I'd like translate to do the language resolution and then get out of the way and return the map of localizations for my options. If it made sense, something like: "k as v for (k, v)

angular-translate ad ng-options

♀尐吖头ヾ 提交于 2019-12-01 00:10:04
问题 I'm trying to translate a select drop-down and I don't like the way I'm doing it, because it's cumbersome and it bypasses the whole angular-translate framework. The locale data looks like {"lang": {"label": "text", "select": {"k1": "var1", "k2": "var2"}}} and if I plonk the "select" member in the controller scope, I can write something like "k as v for (k,v) in scopedvar" in the ng-options of the select. Basically I'd like translate to do the language resolution and then get out of the way

How to best organize translation strings in angular-translate?

寵の児 提交于 2019-11-30 12:47:11
问题 I am using angular-translate on a rather large Angular project. I am breaking the project into multiple modules to make it more manageable, but I am unable to break up my translation strings per module. For example, I have modules A and B, where B is a submodule of A. There are strings that pertain to the HTML covered by module A, which are placed in '/json/localization/A/en.json'. Likewise, there are strings pertaining to B that I place in '/json/localization/B/en.json'. First I load B's en

How to best organize translation strings in angular-translate?

半城伤御伤魂 提交于 2019-11-30 03:03:44
I am using angular-translate on a rather large Angular project. I am breaking the project into multiple modules to make it more manageable, but I am unable to break up my translation strings per module. For example, I have modules A and B, where B is a submodule of A. There are strings that pertain to the HTML covered by module A, which are placed in '/json/localization/A/en.json'. Likewise, there are strings pertaining to B that I place in '/json/localization/B/en.json'. First I load B's en.json in module B using angular-translate's $translationProvider. Then I load module A's en.json, also

Get current language with angular-translate

自古美人都是妖i 提交于 2019-11-29 20:14:02
Is there a way to get the current used language in a controller (without $translateProvider )? Couldn't find anything in the $translate service. charlietfl $translate.use() is a getter and setter. See this demo found in links of docs: http://jsfiddle.net/PascalPrecht/eUGWJ/7/ $translate.use() is the way to go. Also, when an asynchronous loader is executed, you might wanna use $translate.proposedLanguage() which returns the language key of the language that is currently loaded but not finished loaded yet. When using angular-translate-loader-static-files I have noticed that $translate

Translating during config phase (using angular-translate)

倾然丶 夕夏残阳落幕 提交于 2019-11-29 15:39:41
I'm developing the i18n part of my Angular web app, and I'd like to use angular-translate in my config phase. I defined some data that I'd like to translate: .state('app.tracking', { url: '/:IdentityIdentifier', params:{ IdentityIdentifier: {squash: false, value: null} }, templateUrl: 'views/pages/tracking.html', data : { title: $filter('translate')('tracking.tracking.TITLE') }, resolve: load([], function(){ return loadGoogleMaps(); }) }) Here's my config declaration: .config( [ '$stateProvider', '$urlRouterProvider', '$locationProvider', 'MODULE_CONFIG', '$httpProvider', '$filter', function (

AngularJS translate: Format dynamic dates

不羁岁月 提交于 2019-11-29 10:02:51
Using AngularJS and angular-translate I am trying to insert a date as parameter in a translated text. The basic task is documented by the translate package: <p>{{ 'MyText' | translate:{myDate:someControllerDate} }}</p> with this in a localized json-file: (english)'MyText': 'This is the date: {{myDate}}.' (danish) 'MyText': 'Dette {{myDate}} er datoen.' This gives me: (english) This is the date: 2015-04-29T00:00:00. (danish) Dette 2015-04-29T00:00:00 er datoen. The problem: I would like to format the date to match the language (or culture, but for now the language will be good enough). The

Exposing the current state name with ui router

孤街醉人 提交于 2019-11-28 19:05:38
I'm trying to implement a language switcher where if a user clicks on "de" from any given page on an "en" side - it takes them to that page of the "de" side. If I console.dir the $state parameter, it exposes the values I'd want with the "current" property of the given $state. If I try to console.dir the $state.current to focus on the values I want, it only gives the parent state property (my current views are nested). My current thinking is, I'm on url/en/content, and dynamically I can then have my lang navigation dynamically load the appropriate destination points into some kind of data

How to ng-translate inside select box option in angularjs

喜夏-厌秋 提交于 2019-11-28 16:58:23
How do I apply ng-translate to translate options inside a select box. For example: Template: <select class="form-control" ng-model="me.gender" ng-options="gender.name for gender in genders"> </select> Controller: $scope.genders = [{code: "M", name:"TXT_MALE"}, {code: "F", name:"TXT_FEMALE"}] enUS.json: { "TXT_MALE": "Male", "TXT_FEMALE": "Female", } I tried adding filter like ng-options="gender.name for gender in genders | translate" but obviously it was adding filter to $scope.genders array instead of single element I tried writing own filter (I am new to this) filter('translateArrayObj', ['