angular-translate

how to include angular translator in better way.?

岁酱吖の 提交于 2019-12-11 03:58:28
问题 In one of my project im using "https://github.com/angular-translate/angular-translate" for static text translation in Client side. in Controller i have code like this: $scope.myName = serverValue.name; in html view i have code like this : <p>{{myName|translate}}</p> And also i saw below code section can be used to translate the run time values. <p translate="{{myName}}"></p> Here my question is "Which is best and Why ? " Note : "Before down voting please leave your comments" 回答1: substantial

Angular Translate - How to handle phrases with links

折月煮酒 提交于 2019-12-11 03:02:04
问题 The two issues that I have are how to handle this are: I am not sure if it is a good idea to let the translator have control of the actual link / action The issue or rendering translated HTML. [its being rendered as text...] Is there a best practice / examples on how to handle translations of phrases that need to have links within them? Would this change if I would like to run some action of the scope when some parts of the text are clicked? e.g. "BY clicking OK you are accepting our Terms of

angular translate update translation table

倖福魔咒の 提交于 2019-12-11 00:26:55
问题 I have created a directive which wraps angular-translate and can also turns into input fields for easy Translating for admin users. When I update a single translation I don't really want to load an entire translation table from my DB after updating 1 row in the DB, because it seems incredibly inefficient. My problem is that I can't seem to find anything in the angular-translate API that will allow me to have access to the front-end Cache. I want to modify the translation map directly without

angular-translate: Translate dynamic value

拟墨画扇 提交于 2019-12-10 10:03:24
问题 We're using angular-translate to translate our app. Regular translations with dynamic number values are no problems, like 'LIVES_LEFT': 'You have {{ lives }} left.' used like <p>{{ 'LIVES_LEFT' | translate:player }}</p> The problem comes when the dynamic value is a string that itself needs to be translated, like 'YOU_HAVE_A_CHILD': 'You have a {{ gender }} that is {{ age }} years old.' Used like <p>{{ 'YOU_HAVE_A_CHILD' | translate:child }}</p> gender in this case should end up resolving to

angularjs ng-repeat the dropdown values from different i18n files

99封情书 提交于 2019-12-08 22:03:54
问题 Here is an example json i18n language file for English: { "project": { "SPONSORINFO": { "MAIN" : "Select the Sponsor Name", "SPONSORLIST": [ {"spons" :"SponsorName 1" }, {"spons" :"SponsorName 2" } ] } } } and here is my html view: <div class="form-group" > <label for="form-field-select-1" translate="project.SPONSORINFO.MAIN"> </label> <select class="form-control" ng-model="myModel.sponsors"> <option ng-repeat="s in projectJSON.project.SPONSORINFO.SPONSORLIST" value="{{s.spons}}">{{s.spons |

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

霸气de小男生 提交于 2019-12-08 17:24:58
问题 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

angular-translate - Fallback language for determinePreferredLanguage()

≡放荡痞女 提交于 2019-12-08 14:43:26
问题 I use angular-translate in my app. How can I register a fallback language if the determinePreferredLanguage() returns a language key my code doesn't know? I want to fall back to english if someone from e.g. Sweden visits my site (language key: sv ). But since I haven't listed sv in my registerAvailableLanguageKeys function, it fails, and the language-keys are shown to the user instead of the translation. $translateProvider .registerAvailableLanguageKeys(['da-dk','en-us'], { 'en_US': 'en-us',

angular-translate: Translate dynamic value

耗尽温柔 提交于 2019-12-05 18:25:34
We're using angular-translate to translate our app. Regular translations with dynamic number values are no problems, like 'LIVES_LEFT': 'You have {{ lives }} left.' used like <p>{{ 'LIVES_LEFT' | translate:player }}</p> The problem comes when the dynamic value is a string that itself needs to be translated, like 'YOU_HAVE_A_CHILD': 'You have a {{ gender }} that is {{ age }} years old.' Used like <p>{{ 'YOU_HAVE_A_CHILD' | translate:child }}</p> gender in this case should end up resolving to 'boy', or 'girl' if the selected language is English, and for example 'Junge', or 'Mädchen', if the

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

别来无恙 提交于 2019-12-03 16:54:15
问题 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 message", "developerMessage": "message for developer" } The error response can also contain optional list of field validation errors. The question is where should we do the translation of user error messages?

angular-translate sanitisation fails with UTF characters

若如初见. 提交于 2019-12-03 11:24:14
问题 On Angular 1.3.x with latest version of angular-translate. Using $sanitize it seems there are problems when using filter or service directly, but it works when using the directive. Suggestions? Here is an example: var myApp = angular.module('myApp', [ 'pascalprecht.translate', 'ngSanitize' ]); myApp.config(function($translateProvider) { $translateProvider.useSanitizeValueStrategy("sanitize"); $translateProvider.preferredLanguage('en'); $translateProvider.translations('en', { UTF: 'öéü', }); }