From 1a8c3d17b2e0955ae9723559844b8f49233ea3c7 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 30 Jul 2014 15:05:13 +0100 Subject: [PATCH] working example of directive for i18n new project button --- services/web/app/views/layout.jade | 6 +++--- services/web/app/views/project/list.jade | 11 ---------- services/web/public/coffee/base.coffee | 1 + .../public/coffee/main/project-list.coffee | 16 ++++++++++++++- .../coffee/utils/i18nextProvider.coffee | 20 ------------------- 5 files changed, 19 insertions(+), 35 deletions(-) diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index c1ed572b3a..86e30d68b1 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -37,9 +37,9 @@ html(itemscope, itemtype='http://schema.org/Product') script(src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js") script(src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.14/angular.min.js") script(src="/js/libs/i18next.js") - //- script(src="/js/libs/ng-i18next/provider.js") - //- script(src="/js/libs/ng-i18next/filter/filter.js") - //- script(src="/js/libs/ng-i18next/directive/directive.js") + script(src="/js/libs/ng-i18next/provider.js") + script(src="/js/libs/ng-i18next/filter/filter.js") + script(src="/js/libs/ng-i18next/directive/directive.js") script. diff --git a/services/web/app/views/project/list.jade b/services/web/app/views/project/list.jade index 7ff274fb06..7544da209c 100644 --- a/services/web/app/views/project/list.jade +++ b/services/web/app/views/project/list.jade @@ -18,17 +18,6 @@ block content } }; - - - $.i18n.init({ - lng: 'en-gb', - fallbackLng: 'en', - resGetPath: 'locales/__lng__.json' - }, function() { - console.log($.t('new_project')); // -> i18n (from en-US resourcefile) - }); - - .content.content-alt(ng-controller="ProjectPageController") .container .row diff --git a/services/web/public/coffee/base.coffee b/services/web/public/coffee/base.coffee index 90d522ead8..8c60e29857 100644 --- a/services/web/public/coffee/base.coffee +++ b/services/web/public/coffee/base.coffee @@ -10,6 +10,7 @@ define [ "ng-context-menu" "underscore" "ngSanitize" + "jm.i18next" ]) return App \ No newline at end of file diff --git a/services/web/public/coffee/main/project-list.coffee b/services/web/public/coffee/main/project-list.coffee index aadd94c568..c526b8b68c 100644 --- a/services/web/public/coffee/main/project-list.coffee +++ b/services/web/public/coffee/main/project-list.coffee @@ -1,6 +1,19 @@ define [ "base" ], (App) -> + + + angular.module('jm.i18next').config ['$i18nextProvider', ($i18nextProvider)-> + console.log("hello") + $i18nextProvider.options = + lng: 'en-GB', + useCookie: false, + useLocalStorage: false, + fallbackLng: 'en', + resGetPath: '/locales/__lng__.json' + ] + + App.factory "queuedHttp", ($http, $q) -> pendingRequests = [] inflight = false @@ -48,7 +61,8 @@ define [ return queuedHttp - App.controller "ProjectPageController", ($scope, $modal, $q, $window, queuedHttp, event_tracking, $timeout) -> + App.controller "ProjectPageController", ($scope, $modal, $q, $window, queuedHttp, event_tracking, $timeout, $i18next) -> + console.log $i18next, $i18next("new_project"), "- NEW PROJECT" $scope.projects = window.data.projects $scope.tags = window.data.tags $scope.allSelected = false diff --git a/services/web/public/coffee/utils/i18nextProvider.coffee b/services/web/public/coffee/utils/i18nextProvider.coffee index f536f3bd05..e69de29bb2 100644 --- a/services/web/public/coffee/utils/i18nextProvider.coffee +++ b/services/web/public/coffee/utils/i18nextProvider.coffee @@ -1,20 +0,0 @@ -define [ - -], () -> - - - console.log "hello", angular.module('jm.i18next') - angular.module('jm.i18next').config ($i18nextProvider)-> - console.log "hello 222" - $i18nextProvider.options = { - lng: 'en-GB', - useCookie: false, - useLocalStorage: false, - fallbackLng: 'dev', - resGetPath: '../locales/__lng__/__ns__.json', - defaultLoadingValue: '' # ng-i18next option, *NOT* directly supported by i18next - } - console.log "SUP" - console.log $i18nextProvider - -