Merge pull request #76 from alberanid/master

i18n
This commit is contained in:
Davide Alberani 2015-05-16 13:45:06 +02:00
commit 2dd65d9171
9 changed files with 717 additions and 137 deletions

2
.gitignore vendored
View file

@ -1,6 +1,8 @@
data/triggers/*.d
ssl/*.pem
angular_app/node_modules/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

21
angular_app/Gruntfile.js vendored Normal file
View file

@ -0,0 +1,21 @@
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
i18nextract: {
default_options: {
src: ['*.html', 'js/*.js'],
lang: ['it_IT'],
dest: '../static/i18n'
}
}
}
);
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-angular-translate');
grunt.registerTask('translate', ['i18nextract']);
grunt.registerTask('default', ['translate']);
};

View file

@ -13,6 +13,7 @@
<script src="/static/js/angular-ui-router.min.js"></script>
<script src="/static/js/angular-websocket.js"></script>
<script src="/static/js/angular-translate.js"></script>
<script src="/static/js/angular-translate-loader-static-files.min.js"></script>
<script src="/static/js/eventman.js"></script>
<script src="/js/app.js"></script>
<script src="/js/i18n.js"></script>

View file

@ -62,20 +62,26 @@ eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$modalIns
);
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '$log',
function ($scope, Event, $modal, $log) {
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '$log', '$translate', '$rootScope',
function ($scope, Event, $modal, $log, $translate, $rootScope) {
$scope.events = Event.all();
$scope.personsOrderProp = 'name';
$scope.eventsOrderProp = "'-begin-date'";
$scope.confirm_delete = 'You really want to delete this event?';
$rootScope.$on('$translateChangeSuccess', function () {
$translate('You really want to delete this event?').then(function (translation) {
$scope.confirm_delete = translation;
});
});
$scope.remove = function(_id) {
var modalInstance = $modal.open({
scope: $scope,
templateUrl: 'modal-confirm-action.html',
controller: 'ModalConfirmInstanceCtrl',
resolve: {
// XXX: must be converted in a i18n-able form.
message: function() { return 'You really want to delete this event?'; }
message: function() { return $scope.confirm_delete; }
}
});
modalInstance.result.then(function() {
@ -90,8 +96,8 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '
);
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log',
function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log) {
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate',
function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate) {
$scope.personsOrder = ["name", "surname"];
$scope.countAttendees = 0;
$scope.message = {};
@ -191,9 +197,12 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
$scope.allPersons = Person.all();
}
$scope.newPerson = {};
// XXX: must be converted in a i18n-able form.
var msg = '' + person_data.name + ' ' + person_data.surname + ' successfully added to event ' + $scope.event.title;
$scope.showMessage({message: msg});
$translate('{{person_name}} {{person_surname}} successfully added to event {{event_title}}',
{person_name: person_data.name, person_surname: person_data.surname, event_title: $scope.event.title}).then(
function (translation) {
$scope.showMessage({message: translation});
}
);
});
});
$scope.query = '';
@ -264,13 +273,20 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
);
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal',
function ($scope, Person, Setting, $modal) {
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal', '$translate', '$rootScope',
function ($scope, Person, Setting, $modal, $translate, $rootScope) {
$scope.persons = Person.all();
$scope.personsOrder = ["name", "surname"];
$scope.customFields = Setting.query({setting: 'person_custom_field',
in_persons_list: true});
$scope.confirm_delete = 'You really want to delete this person?';
$rootScope.$on('$translateChangeSuccess', function () {
$translate('You really want to delete this person?').then(function (translation) {
$scope.confirm_delete = translation;
});
});
$scope.updateOrded = function(key) {
var new_order = [key];
var inv_key;
@ -303,8 +319,7 @@ eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting'
templateUrl: 'modal-confirm-action.html',
controller: 'ModalConfirmInstanceCtrl',
resolve: {
// XXX: must be converted in a i18n-able form.
message: function() { return 'You really want to delete this person?'; }
message: function() { return $scope.confirm_delete; }
}
});
modalInstance.result.then(function() {

View file

@ -1,13 +1,16 @@
/* i18n for Event(man) */
eventManApp.config(['$translateProvider', function ($translateProvider) {
$translateProvider.translations('it_IT', {
'Events': 'Eventi',
'Add event': 'Nuovo evento',
'Persons': 'Persone',
'Add person': 'Nuova persona',
'Import persons': 'Importa persone',
console.log($translateProvider);
$translateProvider.useStaticFilesLoader({
prefix: '/static/i18n/',
suffix: '.json'
});
$translateProvider.preferredLanguage('it_IT');
$translateProvider.useSanitizeValueStrategy('escaped');
//$translateProvider.preferredLanguage('it_IT');
//$translateProvider.fallbackLanguage('en_US');
}]);

58
static/i18n/it_IT.json Normal file
View file

@ -0,0 +1,58 @@
{
"Info": "",
"New event": "",
"save": "",
"Title": "",
"begin date:": "",
"begin time:": "",
"End date:": "",
"End time:": "",
"Edit": "",
"Registered:": "",
"Attendees:": "",
"Persons": "",
"Search:": "",
"Name or email": "",
"Person": "",
"Name": "",
"Surname": "",
"Attended": "",
"Delete": "",
"Quick add": "",
"Email": "",
"name.surname@example.com": "",
"Company": "",
"Acme Corporation": "",
"Job": "",
"Evil Ruler": "",
"Add": "",
"Unregistered persons": "",
"Events": "",
"Add event": "",
"Event title": "",
"Title (descending)": "",
"Date": "",
"Date (descending)": "",
"Event": "",
"Begins:": "",
"Ends:": "",
"Import persons": "",
"Import persons from eventbrite CSV": "",
"CSV file": "",
"CSV exported from eventbrite": "",
"Associate users to this event": "",
"Import": "",
"logout": "",
"Confirm": "",
"Ok": "",
"Cancel": "",
"New person": "",
"Add to event:": "",
"Sort by:": "",
"Registered": "",
"Add person": "",
"Persons:": "",
"You really want to delete this event?": "",
"{{person_name}} {{person_surname}} successfully added to event {{event_title}}": "",
"You really want to delete this person?": ""
}

View file

@ -0,0 +1,6 @@
/*!
* angular-translate - v2.7.0 - 2015-05-02
* http://github.com/angular-translate/angular-translate
* Copyright (c) 2015 ; Licensed MIT
*/
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return b()}):"object"==typeof exports?module.exports=b():b()}(this,function(){function a(a,b){"use strict";return function(c){if(!(c&&(angular.isArray(c.files)||angular.isString(c.prefix)&&angular.isString(c.suffix))))throw new Error("Couldn't load static files, no files and prefix or suffix specified!");c.files||(c.files=[{prefix:c.prefix,suffix:c.suffix}]);for(var d=function(d){if(!d||!angular.isString(d.prefix)||!angular.isString(d.suffix))throw new Error("Couldn't load static file, no prefix or suffix specified!");var e=a.defer();return b(angular.extend({url:[d.prefix,c.key,d.suffix].join(""),method:"GET",params:""},c.$http)).success(function(a){e.resolve(a)}).error(function(){e.reject(c.key)}),e.promise},e=a.defer(),f=[],g=c.files.length,h=0;g>h;h++)f.push(d({prefix:c.files[h].prefix,key:c.key,suffix:c.files[h].suffix}));return a.all(f).then(function(a){for(var b=a.length,c={},d=0;b>d;d++)for(var f in a[d])c[f]=a[d][f];e.resolve(c)},function(a){e.reject(a)}),e.promise}}return angular.module("pascalprecht.translate").factory("$translateStaticFilesLoader",a),a.$inject=["$q","$http"],a.displayName="$translateStaticFilesLoader","pascalprecht.translate"});

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long