From 0266dd119b78b92ae5b2bd24d8f8ab1e616362be Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 5 May 2016 16:00:58 +0300 Subject: [PATCH] translate app + add french translation --- .../forms/base/config/forms.client.config.js | 4 +-- .../modules/forms/base/config/i18n/english.js | 32 +++++++++++++++++++ .../modules/forms/base/config/i18n/french.js | 27 ++++++++++++++++ .../submit-form.client.controller.js | 8 +++-- public/modules/forms/base/demo/boot.js | 2 +- public/modules/forms/base/demo/index.html | 30 ++++++++++++++++- .../base/directives/field.client.directive.js | 2 +- .../submit-form.client.directive.js | 12 ++++++- .../directiveViews/entryPage/startPage.html | 6 ++-- .../base/views/directiveViews/field/date.html | 4 +-- .../views/directiveViews/field/dropdown.html | 6 ++-- .../views/directiveViews/field/legal.html | 18 +++++------ .../views/directiveViews/field/radio.html | 8 ++--- .../views/directiveViews/field/rating.html | 2 +- .../views/directiveViews/field/statement.html | 4 +-- .../views/directiveViews/field/textarea.html | 4 +-- .../views/directiveViews/field/textfield.html | 26 +++++++-------- .../views/directiveViews/field/yes_no.html | 29 ++++++++++------- .../form/submit-form.client.view.html | 27 ++++++++-------- 19 files changed, 179 insertions(+), 72 deletions(-) create mode 100644 public/modules/forms/base/config/i18n/english.js create mode 100644 public/modules/forms/base/config/i18n/french.js diff --git a/public/modules/forms/base/config/forms.client.config.js b/public/modules/forms/base/config/forms.client.config.js index 8bd182e9..6b04a479 100644 --- a/public/modules/forms/base/config/forms.client.config.js +++ b/public/modules/forms/base/config/forms.client.config.js @@ -1,8 +1,8 @@ 'use strict'; // Configuring the Forms drop-down menus -angular.module('forms').filter('formValidity', -function(){ +angular.module('forms') +.filter('formValidity', function(){ return function(formObj){ if(formObj && formObj.form_fields && formObj.visible_form_fields){ diff --git a/public/modules/forms/base/config/i18n/english.js b/public/modules/forms/base/config/i18n/english.js new file mode 100644 index 00000000..d5a9c7c1 --- /dev/null +++ b/public/modules/forms/base/config/i18n/english.js @@ -0,0 +1,32 @@ +'use strict'; + +angular.module('forms').config(['$translateProvider', function ($translateProvider) { + + $translateProvider.translations('english', { + FORM_SUCCESS: 'Form entry successfully submitted!', + BACK_TO_FORM: 'Go back to Form', + EDIT_FORM: 'Edit this TellForm', + CREATE_FORM: 'Create this TellForm', + ADVANCEMENT: '{{done}} out of {{total}} answered', + CONTINUE_FORM: 'Continue to Form', + REQUIRED: 'required', + OPTIONAL: 'optional', + ERROR_EMAIL_INVALID: 'Please enter a valid email address', + ERROR_NOT_A_NUMBER: 'Please enter valid numbers only', + ERROR_URL_INVALID: 'Please a valid url', + OK: 'OK', + ENTER: 'press ENTER', + CONTINUE: 'Continue', + LEGAL_ACCEPT: 'I accept', + LEGAL_NO_ACCEPT: 'I don’t accept', + DELETE: 'Delete', + CANCEL: 'Cancel', + UPLOAD_FILE: 'Upload your File' + + }); + + $translateProvider.preferredLanguage('english') + .fallbackLanguage('english') + .useSanitizeValueStrategy('escape'); + +}]); diff --git a/public/modules/forms/base/config/i18n/french.js b/public/modules/forms/base/config/i18n/french.js new file mode 100644 index 00000000..3a346b8c --- /dev/null +++ b/public/modules/forms/base/config/i18n/french.js @@ -0,0 +1,27 @@ +'use strict'; + +angular.module('forms').config(['$translateProvider', function ($translateProvider) { + + $translateProvider.translations('french', { + FORM_SUCCESS: 'Votre formulaire a été enregistré!', + BACK_TO_FORM: 'Retourner au formulaire', + EDIT_FORM: 'Éditer le Tellform', + CREATE_FORM: 'Créer un TellForm', + ADVANCEMENT: '{{done}} complétés sur {{total}}', + CONTINUE_FORM: 'Aller au formulaire', + REQUIRED: 'obligatoire', + OPTIONAL: 'facultatif', + ERROR_EMAIL_INVALID: 'Merci de rentrer une adresse mail valide', + ERROR_NOT_A_NUMBER: 'Merce de ne rentrer que des nombres', + ERROR_URL_INVALID: 'Merci de rentrer une url valide', + OK: 'OK', + ENTER: 'presser ENTRÉE', + CONTINUE: 'Continuer', + LEGAL_ACCEPT: 'J’accepte', + LEGAL_NO_ACCEPT: 'Jen n’accepte pas', + DELETE: 'Supprimer', + CANCEL: 'Réinitialiser', + UPLOAD_FILE: 'Envoyer des fichier' + }); + +}]); diff --git a/public/modules/forms/base/controllers/submit-form.client.controller.js b/public/modules/forms/base/controllers/submit-form.client.controller.js index c2919531..e15df9e6 100644 --- a/public/modules/forms/base/controllers/submit-form.client.controller.js +++ b/public/modules/forms/base/controllers/submit-form.client.controller.js @@ -1,10 +1,13 @@ 'use strict'; // SubmitForm controller -angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm', 'Auth', - function($scope, $rootScope, $state, myForm, Auth) { +angular.module('forms').controller('SubmitFormController', [ + '$scope', '$rootScope', '$state', '$translate', 'myForm', 'Auth', + function($scope, $rootScope, $state, $translate, myForm, Auth) { $scope.authentication = Auth; $scope.myform = myForm; + console.log(myForm); + $translate.use(myForm.language); if(!$scope.myform.isLive){ // Show navbar if form is not public AND user IS loggedin @@ -19,6 +22,5 @@ angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScop }else{ $scope.hideNav = $rootScope.hideNav = true; } - } ]); diff --git a/public/modules/forms/base/demo/boot.js b/public/modules/forms/base/demo/boot.js index 7f9c368f..a889417d 100644 --- a/public/modules/forms/base/demo/boot.js +++ b/public/modules/forms/base/demo/boot.js @@ -1,5 +1,5 @@ -angular.module('forms', ['duScroll', 'ngResource', 'NodeForm.templates']); +angular.module('forms', ['duScroll', 'ngResource', 'NodeForm.templates', 'pascalprecht.translate']); angular.module('NodeForm', [ 'ui.select', 'cgBusy', 'ngSanitize', 'vButton', 'ngResource', diff --git a/public/modules/forms/base/demo/index.html b/public/modules/forms/base/demo/index.html index d94659ce..61083082 100644 --- a/public/modules/forms/base/demo/index.html +++ b/public/modules/forms/base/demo/index.html @@ -39,7 +39,34 @@ @@ -68,6 +95,7 @@ + diff --git a/public/modules/forms/base/directives/field.client.directive.js b/public/modules/forms/base/directives/field.client.directive.js index 5d10b613..6ec0726e 100644 --- a/public/modules/forms/base/directives/field.client.directive.js +++ b/public/modules/forms/base/directives/field.client.directive.js @@ -18,7 +18,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root if (__indexOf.call(supportedFields, type) >= 0) { templateUrl = templateUrl+type+'.html'; } - return $templateCache.get('../public/'+templateUrl); + return $templateCache.get(templateUrl); }; return { diff --git a/public/modules/forms/base/directives/submit-form.client.directive.js b/public/modules/forms/base/directives/submit-form.client.directive.js index 12037bcc..440fc997 100644 --- a/public/modules/forms/base/directives/submit-form.client.directive.js +++ b/public/modules/forms/base/directives/submit-form.client.directive.js @@ -11,12 +11,17 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter' $scope.authentication = $rootScope.authentication; $scope.noscroll = false; $scope.forms = {}; - $scope.form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ + + var form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ if(field.fieldType === 'statement' || field.fieldType === 'rating'){ return false; } return true; }).length; + $scope.translateAdvancementData = { + done: $filter('formValidity')($scope.myform), + total: form_fields_count + }; $scope.reloadForm = function(){ //Reset Form @@ -109,6 +114,11 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter' $scope.selected._id = field_id; $scope.selected.index = field_index; + $scope.translateAdvancementData = { + done: $filter('formValidity')($scope.myform), + total: form_fields_count + }; + if(animateScroll){ $scope.noscroll=true; setTimeout(function() { diff --git a/public/modules/forms/base/views/directiveViews/entryPage/startPage.html b/public/modules/forms/base/views/directiveViews/entryPage/startPage.html index 212a9d7e..d13f1715 100644 --- a/public/modules/forms/base/views/directiveViews/entryPage/startPage.html +++ b/public/modules/forms/base/views/directiveViews/entryPage/startPage.html @@ -9,7 +9,7 @@

@@ -18,7 +18,7 @@

\ No newline at end of file +
diff --git a/public/modules/forms/base/views/directiveViews/field/date.html b/public/modules/forms/base/views/directiveViews/field/date.html index 5000ccb9..e7f02391 100755 --- a/public/modules/forms/base/views/directiveViews/field/date.html +++ b/public/modules/forms/base/views/directiveViews/field/date.html @@ -6,8 +6,8 @@ {{index+1}} - {{field.title}} - optional + {{field.title}} + {{ 'OPTIONAL' | translate }}

{{field.description}} diff --git a/public/modules/forms/base/views/directiveViews/field/dropdown.html b/public/modules/forms/base/views/directiveViews/field/dropdown.html index 4908c365..ec5cba2c 100755 --- a/public/modules/forms/base/views/directiveViews/field/dropdown.html +++ b/public/modules/forms/base/views/directiveViews/field/dropdown.html @@ -6,8 +6,8 @@ {{index+1}} - {{field.title}} - optional + {{field.title}} + {{ 'OPTIONAL' | translate }}

{{field.description}} @@ -30,7 +30,7 @@ ng-class="{'active': option.option_value === field.fieldValue }"> - +
diff --git a/public/modules/forms/base/views/directiveViews/field/legal.html b/public/modules/forms/base/views/directiveViews/field/legal.html index edcc53f2..04fff652 100644 --- a/public/modules/forms/base/views/directiveViews/field/legal.html +++ b/public/modules/forms/base/views/directiveViews/field/legal.html @@ -1,14 +1,14 @@


diff --git a/public/modules/forms/base/views/directiveViews/field/radio.html b/public/modules/forms/base/views/directiveViews/field/radio.html index 0aa34660..92c50a7e 100755 --- a/public/modules/forms/base/views/directiveViews/field/radio.html +++ b/public/modules/forms/base/views/directiveViews/field/radio.html @@ -9,7 +9,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}

{{field.description}} @@ -28,12 +28,12 @@ type="radio" class="focusOn" ng-focus="setActiveField(field._id, index, true)" value="{{option.option_value}}" - ng-model="field.fieldValue" - ng-model-options="{ debounce: 250 }" + ng-model="field.fieldValue" + ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled" ng-change="$root.nextField()"/> - + diff --git a/public/modules/forms/base/views/directiveViews/field/rating.html b/public/modules/forms/base/views/directiveViews/field/rating.html index c449c482..23a6c0b0 100644 --- a/public/modules/forms/base/views/directiveViews/field/rating.html +++ b/public/modules/forms/base/views/directiveViews/field/rating.html @@ -7,7 +7,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}

{{field.description}} diff --git a/public/modules/forms/base/views/directiveViews/field/statement.html b/public/modules/forms/base/views/directiveViews/field/statement.html index 5ca40295..99e8045e 100644 --- a/public/modules/forms/base/views/directiveViews/field/statement.html +++ b/public/modules/forms/base/views/directiveViews/field/statement.html @@ -13,11 +13,11 @@

{{field.description}}


-
diff --git a/public/modules/forms/base/views/directiveViews/field/textarea.html b/public/modules/forms/base/views/directiveViews/field/textarea.html index 7a7d656d..5280d88a 100755 --- a/public/modules/forms/base/views/directiveViews/field/textarea.html +++ b/public/modules/forms/base/views/directiveViews/field/textarea.html @@ -37,11 +37,11 @@ ng-click="$root.nextField()" class="btn col-sm-5 col-xs-5"> - OK + {{ 'OK' | translate }}
- press ENTER + {{ 'ENTER' | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/textfield.html b/public/modules/forms/base/views/directiveViews/field/textfield.html index cff51f5c..fc281d65 100755 --- a/public/modules/forms/base/views/directiveViews/field/textfield.html +++ b/public/modules/forms/base/views/directiveViews/field/textfield.html @@ -10,7 +10,7 @@ {{field.title}} - (optional) + ({{ 'OPTIONAL' | translate }}) @@ -19,15 +19,15 @@

-
-
+
diff --git a/public/modules/forms/base/views/directiveViews/field/yes_no.html b/public/modules/forms/base/views/directiveViews/field/yes_no.html index 32b77cf4..244d8d4b 100644 --- a/public/modules/forms/base/views/directiveViews/field/yes_no.html +++ b/public/modules/forms/base/views/directiveViews/field/yes_no.html @@ -10,7 +10,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}

@@ -22,35 +22,42 @@

Yes
- +