angular-translate

Localize URL's with ui-router and angular-translate

怎甘沉沦 提交于 2020-01-19 04:46:27
问题 I am using ui-router for routing and angular-translate for translations. What i would like to achieve is having the selected language bind to the url like so: www.mydomain.com/en/ www.mydomain.com/ru/ www.mydomain.com/en/about www.mydomain.com/ru/about and it will respond accordingly. Tried to look for examples, but did not find anything. If someone implemented similar solution, i would love to hear how you did it. Thanks 回答1: I use something along these lines: CoffeeScript angular.module(

Translating during config phase (using angular-translate)

 ̄綄美尐妖づ 提交于 2020-01-10 05:29:06
问题 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( [ '

Can't get $translate service from angular-translate to change dropdown array for ngDropdowns

谁都会走 提交于 2020-01-06 08:52:35
问题 angular-translate is working to change my HTML. I have an array of selection items for the ngDropdown button directive that also has to change. After changing languages, I try to get the new/current language with translate.use(). Something doesn't work. Here's the HTML <div id="postBox" class="floatingSection" data-ng-controller="postButtonController2"> <button id="postButton" dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected" class="btn-menu" ng-click="getCurrentLanguage()">{{

Can't get $translate service from angular-translate to change dropdown array for ngDropdowns

左心房为你撑大大i 提交于 2020-01-06 08:51:13
问题 angular-translate is working to change my HTML. I have an array of selection items for the ngDropdown button directive that also has to change. After changing languages, I try to get the new/current language with translate.use(). Something doesn't work. Here's the HTML <div id="postBox" class="floatingSection" data-ng-controller="postButtonController2"> <button id="postButton" dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected" class="btn-menu" ng-click="getCurrentLanguage()">{{

angular translate using useStaticFilesLoader to load nested json

风格不统一 提交于 2020-01-04 07:50:18
问题 I have a nested json structure like this { "module1": { "component1": "text1", "component2": "text2" } } So inside my code I am using {"module1.component1" | translate} which never get resolved whereas if I do { "component1": "text1", "component2": "text2" } {"component1" | translate} works . Is there a way to resolve nested JSON data using useStaticFilesLoader edit 1: here is my useStaticFilesLoader config looks like : $translateProvider.useStaticFilesLoader({ prefix: './langfiles/', suffix:

How to translate a date object using angular-translate?

邮差的信 提交于 2020-01-02 03:42:23
问题 I have a list of date in my view, powered by my controller. I am using angular-translate to manage localisation in my all application but do not know how to deal with date object. My HTML looks like this : <div ng-repeat="date in nextDates"> <div class="day">{{date | date: 'EEEE'}}</div> </div> This code display a list a day : Monday, Tuesday, ... based on date which is a date object. My first try was to use moment.js which is already used in this project, and deal really well with i18n. It

How do I used angularjs translator conditionally for HTML label

情到浓时终转凉″ 提交于 2019-12-25 06:38:07
问题 How do I use angular translator for below condition? <label class="control-label col-md-3">{{vm.showVat ? Inclusive : Amount}} </label> 回答1: You can use the translate filter in this way: {{vm.showVat ? 'Inclusive' : 'Amount' | translate}}" Where 'Inclusive' and 'Amount' are the keys for the translated values 回答2: How calling a method that returns you translated text. You can put as much logic as you like in there and it is much easier to test than using angular.element 来源: https:/

Use Strings as Keys in angular-translate - AngularJS

て烟熏妆下的殇ゞ 提交于 2019-12-25 04:42:37
问题 I notice in all of the examples of angular-translate that they use translation ids like "errorMessage" as opposed to using the actual error message string like gettext does. Example: {{'errorMessage' | translate }} instead of {{'Uh oh, something went wrong!' | translate}} Q Why should/shouldn't one use the string as the actual translation id? It seems that it would improve readability and allow for easier translation of the resulting .json file. 来源: https://stackoverflow.com/questions

apply bold text on part of string Angular

做~自己de王妃 提交于 2019-12-25 02:44:26
问题 I would like to make a part of my text bold. I get a text from a specific file. "INFORMATION": "Here's an example of text", I would want that Here's an to be bold. "INFORMATION": "<b>Here's an</b> example of text", "INFORMATION": "<strong>Here's an</strong> example of text" Then I print it <span translate>INFORMATION</span> Instead of getting Here's an example of text I get <b>Here's an</b> example of text or <strong>Here's an</strong> example of text UPDATE I'm trying innerHTML <span

How to fix angular-translate FOUC issues while using translatePartialLoader?

a 夏天 提交于 2019-12-24 16:24:48
问题 I've been experiencing FOUC (flash of untranslated content) issues while using angular-translate. This is my setup: .config(function ($translateProvider, defaultI18n) { $translateProvider .useSanitizeValueStrategy('sanitize') .translations('en-GB', defaultI18n.en) .useCookieStorage() .useLoader('$translatePartialLoader', { urlTemplate: '/{part}/{lang}.json' }) .preferredLanguage('en-GB') .fallbackLanguage('en-GB'); }) .run(function ($rootScope, $translate) { $rootScope.$on('