Permalink
Browse files

Adds I18N

  • Loading branch information...
maciejlew committed Apr 25, 2016
1 parent e6cdb47 commit 030e2680373f6f51471b34e085b1c687303a49f6
View
@@ -14,6 +14,8 @@ module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
+ grunt.loadNpmTasks('grunt-angular-gettext');
+
// Define the configuration for all the tasks
grunt.initConfig({
@@ -27,7 +29,7 @@ module.exports = function (grunt) {
test: 'test',
dist: 'www'
},
-
+
// Environment Variables for Angular App
// This creates an Angular Module that can be injected via ENV
// Add any desired constants to the ENV objects below.
@@ -379,7 +381,26 @@ module.exports = function (grunt) {
dest: '.temp/concat/<%= yeoman.scripts %>'
}]
}
- }
+ },
+
+ nggettext_extract: {
+ pot: {
+ options: {
+ attributes: ['placeholder']
+ },
+ files: {
+ 'app/locale/en_UK/LC_MESSAGES/ddf.pot': ['app/partials/*.html']
+ }
+ },
+ },
+
+ nggettext_compile: {
+ all: {
+ files: {
+ 'app/scripts/translations.js': ['app/locale/**/*.po']
+ }
+ },
+ },
});
View
@@ -26,6 +26,7 @@
<script src="bower_components/ionic/release/js/ionic.js"></script>
<script src="bower_components/ionic/release/js/ionic-angular.js"></script>
<script src="bower_components/ngCordova/dist/ng-cordova.js"></script>
+ <script src="bower_components/angular-gettext/dist/angular-gettext.js"></script>
<!-- endbower -->
<!-- endbuild -->
@@ -34,6 +35,7 @@
<!-- your app's js -->
<!-- build:js scripts/scripts.js -->
+ <script src="scripts/translations.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers.js"></script>
<script src="scripts/configuration.js"></script>
@@ -0,0 +1,51 @@
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Project-Id-Version: Drug Dose Framework 0.1\n"
+"Language: de_DE\n"
+
+#: app/partials/drug-list.html:6
+msgid "Type drug name"
+msgstr "Schreiben Sie die Medikamentennamen"
+
+#: app/partials/drug-dose.html:14
+msgid "calculate"
+msgstr "berechnen"
+
+#: app/partials/drug-list.html:20
+msgid "calculate dose"
+msgstr "berechnen Dosis"
+
+#: app/partials/drug-dose-exception.html:9
+#: app/partials/drug-dose-result.html:12
+msgid "close"
+msgstr "schließen"
+
+#: app/partials/drug-details.html:13
+msgid "description"
+msgstr "Beschreibung"
+
+#: app/partials/drug-dose-result.html:3
+msgid "dose"
+msgstr "Dosis"
+
+#: app/partials/drug-details.html:9
+msgid "drug"
+msgstr "Arzneimittel"
+
+#: app/partials/drug-dose-exception.html:3
+msgid "exception occured"
+msgstr "Ausnahme ist aufgetreten"
+
+#: app/partials/drug-list.html:17
+msgid "show details"
+msgstr "Details anzeigen"
+
+#: app/partials/drug-details.html:17
+msgid "type"
+msgstr "Typ"
+
+#: app/partials/drug-dose.html:10
+msgid "weight"
+msgstr "Gewicht"
@@ -0,0 +1,54 @@
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Project-Id-Version: \n"
+
+#: app/partials/drug-list.html:6
+msgid "Type drug name"
+msgstr ""
+
+#: app/partials/drug-dose.html:11
+msgid "[kg]"
+msgstr ""
+
+#: app/partials/drug-dose.html:14
+msgid "calculate"
+msgstr ""
+
+#: app/partials/drug-list.html:20
+msgid "calculate dose"
+msgstr ""
+
+#: app/partials/drug-dose-exception.html:9
+#: app/partials/drug-dose-result.html:12
+msgid "close"
+msgstr ""
+
+#: app/partials/drug-details.html:13
+msgid "description"
+msgstr ""
+
+#: app/partials/drug-dose-result.html:3
+msgid "dose"
+msgstr ""
+
+#: app/partials/drug-details.html:9
+msgid "drug"
+msgstr ""
+
+#: app/partials/drug-dose-exception.html:3
+msgid "exception occured"
+msgstr ""
+
+#: app/partials/drug-list.html:17
+msgid "show details"
+msgstr ""
+
+#: app/partials/drug-details.html:17
+msgid "type"
+msgstr ""
+
+#: app/partials/drug-dose.html:10
+msgid "weight"
+msgstr ""
@@ -0,0 +1,51 @@
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Project-Id-Version: Drug Dose Framework 0.1\n"
+"Language: pl_PL\n"
+
+#: app/partials/drug-list.html:6
+msgid "Type drug name"
+msgstr "Wpisz nazwę leku"
+
+#: app/partials/drug-dose.html:14
+msgid "calculate"
+msgstr "oblicz"
+
+#: app/partials/drug-list.html:20
+msgid "calculate dose"
+msgstr "oblicz dawkę"
+
+#: app/partials/drug-dose-exception.html:9
+#: app/partials/drug-dose-result.html:12
+msgid "close"
+msgstr "zamknij"
+
+#: app/partials/drug-details.html:13
+msgid "description"
+msgstr "opis"
+
+#: app/partials/drug-dose-result.html:3
+msgid "dose"
+msgstr "dawka"
+
+#: app/partials/drug-details.html:9
+msgid "drug"
+msgstr "lek"
+
+#: app/partials/drug-dose-exception.html:3
+msgid "exception occured"
+msgstr "wystąpił wyjątek"
+
+#: app/partials/drug-list.html:17
+msgid "show details"
+msgstr "pokaż szczegóły"
+
+#: app/partials/drug-details.html:17
+msgid "type"
+msgstr "typ"
+
+#: app/partials/drug-dose.html:10
+msgid "weight"
+msgstr "waga"
@@ -6,15 +6,15 @@
can-swipe="listCanSwipe">
<ion-item class="item-icon-left">
<i class="icon ion-erlenmeyer-flask"></i>
- Drug: {{drug.getName()}}
+ <span translate>drug</span>: {{drug.getName()}}
</ion-item>
<ion-item class="item-icon-left">
<i class="icon ion-clipboard"></i>
- Description: {{drug.getDescription()}}
+ <span translate>description</span>: {{drug.getDescription()}}
</ion-item>
<ion-item class="item-icon-left">
<i class="icon ion-funnel"></i>
- Type: {{drug.getType()}}
+ <span translate>type</span>: {{drug.getType()}}
</ion-item>
</ion-list>
</ion-content>
@@ -1,13 +1,13 @@
<ion-modal-view>
<ion-header-bar class="bar-assertive">
- <h1 class="title">Exception occured!</h1>
+ <h1 class="title" translate>exception occured</h1>
</ion-header-bar>
<ion-content class="modal-content">
<div>
<span>{{exception}}</span>
</div>
- <button class="button button-large button-assertive" ng-click="closeExceptionModal()">
- Close
+ <button class="button button-large button-assertive" ng-click="closeExceptionModal()" translate>
+ close
</button>
</ion-content>
</ion-modal-view>
@@ -1,6 +1,6 @@
<ion-modal-view>
<ion-header-bar class="bar-positive">
- <h1 class="title">Dose:</h1>
+ <h1 class="title" translate>dose</h1>
</ion-header-bar>
<ion-content class="modal-content">
<div>
@@ -9,8 +9,8 @@ <h1 class="title">Dose:</h1>
<span id="dose-max">{{dose.getMax()}}</span>
[mg]
</div>
- <button class="button button-large button-positive" ng-click="closeDoseModal()">
- Close
+ <button class="button button-large button-positive" ng-click="closeDoseModal()" translate>
+ close
</button>
</ion-content>
</ion-modal-view>
@@ -7,12 +7,12 @@
{{drug.getName()}}
</div>
<label class="item item-input item-stacked-label">
- <span class="input-label">Weight</span>
+ <span class="input-label" translate>weight</span>
<input ng-model="input.weight" type="number" placeholder="[kg]" min="0">
</label>
<div class="item">
- <button type="submit" class="button button-block button-positive">
- Calculate
+ <button type="submit" class="button button-block button-positive" translate>
+ calculate
</button>
</div>
</div>
@@ -14,10 +14,10 @@
{{drug.name}}
</ion-reorder-button>
<ion-option-button class="button-balanced" ui-sref="drug-details({drugId: drug.id})">
- <i class="ion-search">Show Details</i>
+ <i class="ion-search" translate>show details</i>
</ion-option-button>
<ion-option-button class="button-royal" ui-sref="drug-dose({drugId: drug.id})">
- <i class="ion-ios-settings">Calculate Dose</i>
+ <i class="ion-ios-settings" translate>calculate dose</i>
</ion-option-button>
</ion-item>
</ion-list>
View
@@ -1,9 +1,19 @@
'use strict';
-(function(){
-
- var dependencies = ['ionic', 'ui.router', 'DrugDoseFrameworkControllers'];
-
- var app = angular.module('DrugDoseFrameworkApp', dependencies).run(function ($ionicPlatform) {
+(function () {
+
+ var dependencies = ['gettext', 'ionic', 'ui.router', 'DrugDoseFrameworkControllers'];
+
+ var app = angular.module('DrugDoseFrameworkApp', dependencies).run(function ($ionicPlatform, gettextCatalog) {
+
+ switch (window.navigator.language.substr(0, 2)) {
+ case 'pl':
+ gettextCatalog.setCurrentLanguage('pl_PL');
+ break;
+ case 'de':
+ gettextCatalog.setCurrentLanguage('de_DE');
+ break;
+ }
+
$ionicPlatform.ready(function () {
if (window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
@@ -20,23 +30,31 @@
}
});
});
-
-
- app.config(function($stateProvider, $urlRouterProvider) {
+
+ app.directive('placeholder', ['gettextCatalog', function (gettextCatalog) {
+ return {
+ restrict: 'A',
+ link: function (scope, element, attrs) {
+ element.attr('placeholder', gettextCatalog.getString(attrs.placeholder));
+ }
+ };
+ }]);
+
+ app.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider.state('drugs', {
- url: '/drugs/',
+ url: '/drugs/',
templateUrl: 'partials/drug-list.html',
controller: 'DrugListCtrl'
}).state('drug-details', {
- url: '/drugs/:drugId',
+ url: '/drugs/:drugId',
templateUrl: 'partials/drug-details.html',
controller: 'DrugDetailsCtrl'
}).state('drug-dose', {
- url: '/drugs/dose/:drugId',
+ url: '/drugs/dose/:drugId',
templateUrl: 'partials/drug-dose.html',
controller: 'DrugDoseCtrl'
});
$urlRouterProvider.otherwise("/drugs/");
});
-
+
})();

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -3,7 +3,8 @@
"version": "0.1.0",
"dependencies": {
"ionic": "^1.1.0",
- "ngCordova": "^0.1.20-alpha"
+ "ngCordova": "^0.1.20-alpha",
+ "angular-gettext": "^2.2.1"
},
"devDependencies": {
"angular-mocks": "^1.3.6",
@@ -13,4 +14,3 @@
"angular": ">= 1.3.6"
}
}
-
Oops, something went wrong.

0 comments on commit 030e268

Please sign in to comment.