This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 7fba1f36ceb4277f097b18af0a703cf44d43e9fd Author: Yannick Martel <martel@©odelutin.com> Date: Mon Feb 2 14:46:22 2015 +0100 fixes #6583 : display date in french when it is the selected language --- coselmar-ui/pom.xml | 6 ++ .../src/main/webapp/i18n/angular-locale_en.js | 115 +++++++++++++++++++++ .../src/main/webapp/i18n/angular-locale_fr.js | 97 +++++++++++++++++ coselmar-ui/src/main/webapp/index.html | 1 + .../src/main/webapp/js/coselmar-controllers.js | 11 +- coselmar-ui/src/main/webapp/js/coselmar.js | 8 +- pom.xml | 8 ++ 7 files changed, 241 insertions(+), 5 deletions(-) diff --git a/coselmar-ui/pom.xml b/coselmar-ui/pom.xml index dd2e721..0c0e52a 100644 --- a/coselmar-ui/pom.xml +++ b/coselmar-ui/pom.xml @@ -83,6 +83,12 @@ <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.webjars</groupId> + <artifactId>angular-dynamic-locale</artifactId> + <scope>runtime</scope> + </dependency> + </dependencies> <build> diff --git a/coselmar-ui/src/main/webapp/i18n/angular-locale_en.js b/coselmar-ui/src/main/webapp/i18n/angular-locale_en.js new file mode 100644 index 0000000..6ca9e4f --- /dev/null +++ b/coselmar-ui/src/main/webapp/i18n/angular-locale_en.js @@ -0,0 +1,115 @@ +'use strict'; +angular.module("ngLocale", [], ["$provide", function($provide) { +var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"}; +function getDecimals(n) { + n = n + ''; + var i = n.indexOf('.'); + return (i == -1) ? 0 : n.length - i - 1; +} + +function getVF(n, opt_precision) { + var v = opt_precision; + + if (undefined === v) { + v = Math.min(getDecimals(n), 3); + } + + var base = Math.pow(10, v); + var f = ((n * base) | 0) % base; + return {v: v, f: f}; +} + +$provide.value("$locale", { + "DATETIME_FORMATS": { + "AMPMS": [ + "AM", + "PM" + ], + "DAY": [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday" + ], + "MONTH": [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ], + "SHORTDAY": [ + "Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat" + ], + "SHORTMONTH": [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ], + "fullDate": "EEEE, MMMM d, y", + "longDate": "MMMM d, y", + "medium": "MMM d, y h:mm:ss a", + "mediumDate": "MMM d, y", + "mediumTime": "h:mm:ss a", + "short": "M/d/yy h:mm a", + "shortDate": "M/d/yy", + "shortTime": "h:mm a" + }, + "NUMBER_FORMATS": { + "CURRENCY_SYM": "$", + "DECIMAL_SEP": ".", + "GROUP_SEP": ",", + "PATTERNS": [ + { + "gSize": 3, + "lgSize": 3, + "maxFrac": 3, + "minFrac": 0, + "minInt": 1, + "negPre": "-", + "negSuf": "", + "posPre": "", + "posSuf": "" + }, + { + "gSize": 3, + "lgSize": 3, + "maxFrac": 2, + "minFrac": 2, + "minInt": 1, + "negPre": "\u00a4-", + "negSuf": "", + "posPre": "\u00a4", + "posSuf": "" + } + ] + }, + "id": "en-us", + "pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;} +}); +}]); diff --git a/coselmar-ui/src/main/webapp/i18n/angular-locale_fr.js b/coselmar-ui/src/main/webapp/i18n/angular-locale_fr.js new file mode 100644 index 0000000..adac17d --- /dev/null +++ b/coselmar-ui/src/main/webapp/i18n/angular-locale_fr.js @@ -0,0 +1,97 @@ +'use strict'; +angular.module("ngLocale", [], ["$provide", function($provide) { +var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"}; +$provide.value("$locale", { + "DATETIME_FORMATS": { + "AMPMS": [ + "AM", + "PM" + ], + "DAY": [ + "dimanche", + "lundi", + "mardi", + "mercredi", + "jeudi", + "vendredi", + "samedi" + ], + "MONTH": [ + "janvier", + "f\u00e9vrier", + "mars", + "avril", + "mai", + "juin", + "juillet", + "ao\u00fbt", + "septembre", + "octobre", + "novembre", + "d\u00e9cembre" + ], + "SHORTDAY": [ + "dim.", + "lun.", + "mar.", + "mer.", + "jeu.", + "ven.", + "sam." + ], + "SHORTMONTH": [ + "janv.", + "f\u00e9vr.", + "mars", + "avr.", + "mai", + "juin", + "juil.", + "ao\u00fbt", + "sept.", + "oct.", + "nov.", + "d\u00e9c." + ], + "fullDate": "EEEE d MMMM y", + "longDate": "d MMMM y", + "medium": "d MMM y HH:mm:ss", + "mediumDate": "d MMM y", + "mediumTime": "HH:mm:ss", + "short": "dd/MM/y HH:mm", + "shortDate": "dd/MM/y", + "shortTime": "HH:mm" + }, + "NUMBER_FORMATS": { + "CURRENCY_SYM": "\u20ac", + "DECIMAL_SEP": ",", + "GROUP_SEP": "\u00a0", + "PATTERNS": [ + { + "gSize": 3, + "lgSize": 3, + "maxFrac": 3, + "minFrac": 0, + "minInt": 1, + "negPre": "-", + "negSuf": "", + "posPre": "", + "posSuf": "" + }, + { + "gSize": 3, + "lgSize": 3, + "maxFrac": 2, + "minFrac": 2, + "minInt": 1, + "negPre": "-", + "negSuf": "\u00a0\u00a4", + "posPre": "", + "posSuf": "\u00a0\u00a4" + } + ] + }, + "id": "fr-fr", + "pluralCat": function(n, opt_precision) { var i = n | 0; if (i == 0 || i == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;} +}); +}]); diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index ffbdc16..ae22b95 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -38,6 +38,7 @@ <!--<script src="nuiton-js/angular-ui-bootstrap.js"></script>--> <script src="webjars/bootstrap/3.3.1/js/bootstrap.js"></script> <script src="webjars/angular-translate/2.5.2/angular-translate.js"></script> + <script src="webjars/angular-dynamic-locale/0.1.24/src/tmhDynamicLocale.js"></script> <!--TODO ymartel 20141203 : extract version, or use wro --> <script src="webjars/angular-ui-select/0.9.0/select.js"></script> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index d9b9026..a25407e 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -21,11 +21,11 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip', 'pascalprecht.translate']); +var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip', 'pascalprecht.translate', 'tmh.dynamicLocale']); // Controller when the main page/view loads -coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$routeParams', '$locale', '$translate', 'userService', 'jwtHelper', 'coselmar-config', - function ($scope, $http, $location, $routeParams, $locale, $translate, userService, jwtHelper, coselmarConfig) { +coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$route', '$routeParams', '$locale', '$translate', 'tmhDynamicLocale', 'userService', 'jwtHelper', 'coselmar-config', + function ($scope, $http, $location, $route, $routeParams, $locale, $translate, tmhDynamicLocale, userService, jwtHelper, coselmarConfig) { var jwtToken = localStorage.getItem('coselmar-jwt'); if (jwtToken && !jwtHelper.isTokenExpired(jwtToken)) { @@ -75,6 +75,7 @@ coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$ro } $translate.use($scope.locale); + tmhDynamicLocale.set($scope.locale); $scope.switchLocale = function (locale) { @@ -84,6 +85,10 @@ coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$ro localStorage.setItem('coselmar-locale', locale); $scope.locale = locale; $translate.use(locale); + // change $locale + tmhDynamicLocale.set(locale); + // reload directives to use the new $locale + $route.reload(false) } } diff --git a/coselmar-ui/src/main/webapp/js/coselmar.js b/coselmar-ui/src/main/webapp/js/coselmar.js index 788b3a9..a444191 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar.js +++ b/coselmar-ui/src/main/webapp/js/coselmar.js @@ -21,7 +21,8 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -var coselmarApp = angular.module("coselmarApp", ['ngRoute', 'ngResource', 'ngMessages', 'pascalprecht.translate', +var coselmarApp = angular.module("coselmarApp", ['ngRoute', 'ngResource', 'ngMessages', + 'pascalprecht.translate', 'tmh.dynamicLocale', 'angular-jwt', 'coselmarControllers', 'coselmarServices']); coselmarApp.config(['$routeProvider', function($routeProvider) { @@ -137,11 +138,14 @@ coselmarApp.config(function($httpProvider) { }); // i18n provider -coselmarApp.config(function($translateProvider) { +coselmarApp.config(function($translateProvider, tmhDynamicLocaleProvider) { // define translations variables $translateProvider.translations('en', translateEN); $translateProvider.translations('fr', translateFR); // defined default $translateProvider.preferredLanguage('en'); $translateProvider.fallbackLanguage('en'); + + tmhDynamicLocaleProvider.localeLocationPattern("i18n/angular-locale_{{locale}}.js"); +// tmhDynamicLocaleProvider.useStorage('$cookieStore'); }); \ No newline at end of file diff --git a/pom.xml b/pom.xml index be4aa3a..fa5218f 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,7 @@ <angularUiSelectVersion>0.9.0</angularUiSelectVersion> <angularUiBootstrapVersion>0.12.0</angularUiBootstrapVersion> <angularTranslateVersion>2.5.2</angularTranslateVersion> + <angularDynamicLocaleVersion>0.1.24</angularDynamicLocaleVersion> </properties> @@ -409,6 +410,13 @@ <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.webjars</groupId> + <artifactId>angular-dynamic-locale</artifactId> + <version>${angularDynamicLocaleVersion}</version> + <scope>runtime</scope> + </dependency> + <!-- Others --> <dependency> <groupId>com.github.spullara.mustache.java</groupId> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.