FAQ Database Discussion Community


Angular Translate doesn't work with multiple translation IDs

angularjs,angular-translate
This doesn't work. Returns a blank. $translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (investEdu, mostUltimate) { Then I tried this, with an object: $translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (translations) { Accessing it like `translations.INVEST_EDU'. First one appears, second one blank. What am I doing wrong here, in making Angular-translate work with multiple translation IDs....

Internationalization of api error messages on front end or back end?

java,angularjs,spring,internationalization,angular-translate
My team is currently working on a web project where the front end uses json api provided by the back end. The technology that we use is Spring Boot and AngularJS. The api has the standard error format that looks like this: { "errorCode": "1111", "message": "Error occurred: some error...

Angular-Translate Variable Replacement in Title Attribute

javascript,html,angularjs,angular-translate
I'm working on an AngularJS application with Angular-Translate 2.6.1. I have a span with a title attribute that will be translated, but it needs to display a variable as well. <span title={{'translationID'|translate:'{username:"Value"}'}}>...</span> I've tried replacing "Value" with {{Value}}, with and without quotes. Value is defined in the scope, and I...

Use translateProvider.useLoader with Typescript

typescript,angular-translate
I am new to AngularJs and Typescript. I am trying to implement I18n. My resource bundles are lying in a remote server. I use $translateProvider.useLoader('TranlationFilesLoader',{}) where TranlationFilesLoader is a custom loader class. TranlationFilesLoader class looks as follows: export class TranlationFilesLoader { public static $inject = ['$http', '$q' ]; constructor( $http:...

AngularJS translation with pluralization using angular-translate

angularjs,translation,angular-translate,pluralize
Hello I need to make translations with pluralization depending on a value, but can't find how to do that. for example I have variable peopleCount. peopleCount = 1 translations should be: english: {{ peopleCount }} person likes this lithuanian: {{ peopleCount }} zmogus tai megsta if peopleCount is more than...

Using $translateProvider.useUrlLoader

angularjs,angular-translate
i am using latest version of angularjs and angular-translate. For some reason, I don't want to store my translations in static .json files (en_US.json or ru_RU.json) Is there any API in angular-translate which calls a REST API which in turn returns json data for translation. REST API will pull the...

Angular-translate: Set custom loader option from controller

angular-translate
Today, I have an config for the translateProvider looking like this: App.config(['$translateProvider', function ($translateProvider) { $translateProvider.preferredLanguage('en-US'); $translateProvider.useLoader('TranslationLoader', { versionIdentifier : 127} ); $translateProvider.useMissingTranslationHandler('MissingTranslationHandler'); }]); The problem is that I don't know the value of the formIdentifier-option at configuration time. I get this value after resolving the first state in ui-route....

AngularJS translate: Format dynamic dates

angularjs,date,angular-translate
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...

How do I use Angular i18n for languages it doesn't appear to support?

javascript,angularjs,internationalization,locale,angular-translate
I am using Angular i18n for German, English, Spanish, French, Italian, Portuguese, Russian, Ukrainian, Japanese, Korean, and Chinese. These are all supported locales, but I've been tasked to include translations for Cebuano, Samoan, Tagalog, and Tongan. These do not appear to be supported locales in Angular i18n. How do I...

angular-translate: how to reset translation table dynamically in $translationProvider?

angularjs,internationalization,ionic,translate,angular-translate
I am using angular-translate to display different languages in my application, but I get an error when I try to refresh the translation data after a successful login or via other web service calls. Note: I successfully invoke $translateProvider.useLoader in my "app.config" to set the default translation data. But I...

Directive inside a angular-translate translation

angularjs,angularjs-directive,angular-translate
I'm using angular-translate for i18n and want to use a directive inside a translation: var translations = { TEST_1: 'Hello from <a href="/test">Test</a>', TEST_2: 'Hello from <user></user>' }; app.directive('user', function() { return { template: '<a href="/test">Test</a>' }; }); Full plnkr example: http://plnkr.co/edit/jCCcvx7IEaAYUwyaQ7uH?p=preview So <p translate="TEST_1"></p> <p translate="TEST_2"></p> should be the...

How to angular translate ng-model property value?

angularjs,angular-translate
In my controller $http service data is assigned to $scope as: $scope.project = data.data; In my view for a text box I have defined: ng-model="project.name" How do I translate ng-model value of project.name using angular-translate?...

AngularJS inject $http into config for angular-translate

angularjs,angular-translate,angularjs-provider
I'm using angular-translate module and am trying to inject all my translations that are on server with $http. I use a provider and I know that only i can inject dependencies through $get but I can't call that function from my provider. I need to know if i can do...

Setting cookie for AngularJS translate locale using PHP

php,angularjs,symfony2,angular-translate
My app uses Symfony and AngularJS. I have translations some with Symfony itself and some with AngularJS angular-translate. How do I set a cookie or session variable to change language for AngularJS from PHP?

Angular-translate's localStorage: Unknown provider: $translateLocalStorageProvider

angularjs,angular-translate
I'm using angular-translate in my Angular (v1.x) app as well as loading translations from files by using $translateProvider.useStaticFilesLoader angular.module('myApp',['pascalprecht.translate']) .config(function($translateProvider) { $translateProvider.useStaticFilesLoader( prefix: window.location.pathname.replace(/[\\\/][^\\\/]*$/, '') + '/__languages/', // absolute path + language path suffix: '.json' }); // $translateProvider.useLocalStorage(); } Angular-translate works perfectly but when it comes to use:...

angular-translate service is not translating for first time

angularjs,angular-translate
I´m using angular-translate $translate service to translate the title and meta description tags content dinamically according to the page (for SEO purposes). I have a function that is called when a select combobox component with the language changes: $scope.changeLanguage = function (langKey) { $scope.langKey = langKey; $translate.uses(langKey); $rootScope.title = $translate('PAGE_TITLE');...

Is there a way I can automate the creation of .json files used for language translations?

javascript,json,angularjs,powershell,angular-translate
I have files such as this that have translation keys and values: locale-en.json { "CHANGE_PASSWORD": "Change Password", "CONFIRM_PASSWORD": "Confirm Password", "NEW_PASSWORD": "New Password" } locale-jp.json { "CHANGE_PASSWORD": "パスワードを変更します", "CONFIRM_PASSWORD": "パスワードを認証します", "NEW_PASSWORD": "新しいパスワード" } When I add a new translation key to the JSON file containing the English translations for example,...

using angular-translate in controller gives me an object object

angularjs,angular-translate
how do i get the text from the $translate ? i get an "[object Object]" if i do it like this: var str = '<b>' + $translate('room') + '</b><br>'; if ($scope.ad.category == '2' || $scope.ad.category == '1') { str = '<b>' + $translate('flat') + '</b><br>'; } else if ($scope.ad.category ==...

Good practice with Angular Translate

angularjs,angular-translate
I'm attempting to use angular translate and I had a best practice question. Is it best practice to use a key for a string like so: app.config(function($translateProvider) { $translateProvider.translations('en', { HEADLINE: 'Hello there, This is my awesome app!', INTRO_TEXT: 'And it has i18n support!' }); }); and <h2>{{ 'HEADLINE' |...

How to nest expressions in AngularJS' views?

angularjs,angular-translate
I'm using Angular Material together with angular-translate. Basically when using AM's md-select I have: <md-select-label>{{ userLanguage ? userLanguage.chosenLanguage: "Choose language"}}</md-select-label> which shows Choose language if no option was selected or the selected option otherwise. Finally I use angular-translate to translate all the label (e.g. "Choose language" in multiple languages) in...

angular-translate module 'pascalprecht.translate' not found

javascript,angularjs,internationalization,angular-translate
I'm trying to add angular-translate to my angular app. I followed this simple quick start: https://angular-translate.github.io/docs/#/guide, but my app won't bootstrap, giving me the following error: Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module pascalprecht.translate due to: Error: [$injector:nomod] Module 'pascalprecht.translate' is...

JSON to HTML with breaklines, angular-translate

javascript,json,angularjs,angular-translate
I'm using Angular-translate and I am trying to load a text from JSON with breakline, but the html is not recognizing. JSON: "ABOUT": { "headline":"Every day\n every moment", "span": "Be Like" } ANGULARJS: .config(function($translateProvider) { // Sanitize $translateProvider.useSanitizeValueStrategy('escaped'); // Load JSON $translateProvider.useStaticFilesLoader({ prefix: '/app/languages/app-', suffix: '.json' }); $translateProvider.preferredLanguage('en'); HTML: <h2>...

translate angular-ui's pagination text angularjs

javascript,angularjs,pagination,angular-ui-bootstrap,angular-translate
i'm been working one a webpage where i use angularjs and angular-ui. And i use the pagination from angular-ui. Now i need to change the next and previous button text after what language $translate are assigned to. I tried to do it inline like this <pagination previous-text="{{'PREVIOUS' | translate}}" </pagination>...

Start Angular.js route-segment or ui-router after all translations are loaded

javascript,angularjs,angular-ui-router,angular-translate
Is there any way, how to start ui-router or route-segment just after translateProvider loads its translations? I'm using pascal prechts translate filter together with bind once {{:: }} notation. On localhost it works pretty good, but when I test it on remote server, bind once will remove watchers sooner than...