Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented translation feature #35

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5631dca
Added angular translate
Shinigami92 Jan 26, 2017
a860690
fix conflicts
Shinigami92 Jan 27, 2017
f0834bd
Merge branch 'Js41637-master'
Shinigami92 Jan 27, 2017
1df0555
Added generator for locales
Shinigami92 Jan 27, 2017
499e0d9
implemented translation for items
Shinigami92 Jan 27, 2017
ed3e4a9
Fix conflicts
Shinigami92 Jan 28, 2017
e47c85d
Merge branch 'Js41637-master'
Shinigami92 Jan 28, 2017
224e6e8
Improved language-selection
Shinigami92 Jan 28, 2017
3aad9e2
Added german YEAR_OF_THE_ROOSTER_2017 translation
Shinigami92 Jan 28, 2017
5fa1e01
Merge pull request #3 from Js41637/master
Shinigami92 Jan 30, 2017
85cf838
Added german translation for WINTER_WONDERLAND_2016
Shinigami92 Jan 30, 2017
1c7a77e
Added german translation for HALLOWEEN_2016
Shinigami92 Jan 30, 2017
2164734
Removed '::' infront of name-variables in views
Shinigami92 Jan 30, 2017
e37b054
Merge branch 'master' into master
Shinigami92 Jan 30, 2017
f151761
Merge pull request #4 from Js41637/master
Shinigami92 Jan 31, 2017
fe73a57
Add german translation for SUMMER_GAMES_2016
Shinigami92 Jan 31, 2017
f06e18b
Added French Translation
nduriez Feb 1, 2017
f209f6b
Merge pull request #5 from Shinigami92/French-Translation
Shinigami92 Feb 1, 2017
a98064b
Fixed " and , in branch from JigAma
Shinigami92 Feb 1, 2017
994347a
Merge master into fork and fix conflicts
Shinigami92 Feb 3, 2017
02bf92a
Merge branch 'Js41637-master'
Shinigami92 Feb 3, 2017
fa6f118
fix translations for new theme
Shinigami92 Feb 3, 2017
f95725a
Revert to static binding
Shinigami92 Feb 3, 2017
58fb429
fix merge conflicts
Shinigami92 Feb 6, 2017
42a1716
Merge branch 'Js41637-master'
Shinigami92 Feb 6, 2017
3c388ae
Merge branch 'master' into master
Shinigami92 Feb 9, 2017
f3c9e07
Resolve conflicts and updated to newest master after new-thing branch
Shinigami92 Apr 17, 2017
8e5248e
Merge branch 'Js41637-master'
Shinigami92 Apr 17, 2017
9a34fd0
Fixed differences from old to new version for locales/de_DE
Shinigami92 Apr 22, 2017
7cf2cf2
Added Uprising 2017 locales/de_DE
Shinigami92 Apr 22, 2017
13062b3
Fixed some halloween translations for locales/de_DE
Shinigami92 Apr 22, 2017
aa67b67
Fixed hero.html grid item.name not translated
Shinigami92 Apr 23, 2017
159b925
Added german all.icons
Shinigami92 Apr 23, 2017
c2a7603
Merge branch 'master' into master
Shinigami92 Aug 5, 2017
f7b8fc9
recreated /locales/en_US.json with /locales/language-generator.html
Shinigami92 Aug 5, 2017
90505e2
added translation to anniversaey_2017 sprays
Shinigami92 Aug 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ body {
margin-bottom: 3px;
}

#settings .setting .flag-icon {
width: 32px;
height: 32px;
border-width: medium;
border-style: solid;
border-color: transparent;
}

#settings .setting .flag-icon-selected {
border-color: #ffa500;
}

strong {
font-weight: bold;
}
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<link rel="stylesheet" href="./css/global.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.1/angular-translate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.1/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.4.2/angular-ui-router.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
<script src="./js/app.js"></script>
Expand Down
14 changes: 12 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
var OWI = angular.module('OWI', ['ui.router', 'ui.bootstrap', 'ngAnimate']);
var OWI = angular.module('OWI', ['ui.router', 'ui.bootstrap', 'ngAnimate', 'pascalprecht.translate']);

// Setup some angular config stuff
OWI.config(['$compileProvider', '$urlMatcherFactoryProvider', '$animateProvider', '$locationProvider', function($compileProvider, $urlMatcherFactoryProvider, $animateProvider, $locationProvider) {
OWI.config(['$compileProvider', '$urlMatcherFactoryProvider', '$animateProvider', '$locationProvider', '$translateProvider', function($compileProvider, $urlMatcherFactoryProvider, $animateProvider, $locationProvider, $translateProvider) {
$locationProvider.hashPrefix(""); // defaults to #! which is annoying
$compileProvider.debugInfoEnabled(false); // more perf
$urlMatcherFactoryProvider.strictMode(false); // I dunno
$animateProvider.classNameFilter(/angular-animate/); // prevent angular-animate animating all the things
$translateProvider.useStaticFilesLoader({prefix: '/locales/', suffix: '.json'});
var settings = localStorage.getItem('settings');
if (settings) {
console.log('Seleced language from localStorage');
$translateProvider.preferredLanguage(JSON.parse(settings).langKey);
} else {
console.log('Seleced default language');
$translateProvider.preferredLanguage('en_US');
}
$translateProvider.fallbackLanguage('en_US');
}]);

// Run migrations to convert data and stuff
Expand Down
21 changes: 17 additions & 4 deletions js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
OWI.controller('MainCtrl', ["$rootScope", "$q", "$document", "$uibModal", "DataService", "CompatibilityService", "CostAndTotalService", function($rootScope, $q, $document, $uibModal, DataService, CompatibilityService, CostAndTotalService) {
OWI.controller('MainCtrl', ["$rootScope", "$q", "$document", "$uibModal", "DataService", "CompatibilityService", "CostAndTotalService", "StorageService", function($rootScope, $q, $document, $uibModal, DataService, CompatibilityService, CostAndTotalService, StorageService) {
var vm = this;
this.preview = false;
this.currentDate = Date.now();
this.showSidebar = false;
this.showNav = false;
this.noSupportMsg = CompatibilityService.noSupportMsg;
this.noSupportMsg = CompatibilityService.noSupportMsg
this.totals = CostAndTotalService;
this.langKey = StorageService.getSetting('langKey');

DataService.waitForInitialization().then(function(data) {
vm.events = data.events;
Expand Down Expand Up @@ -217,7 +218,7 @@ OWI.controller('HeroesCtrl', ["$scope", "$rootScope", "$uibModal", "DataService"
vm.clearFilters();
return;
}

this.filteredItems = filterItems(hero.items, eventFilters, groupFilter);
updateCosts();

Expand Down Expand Up @@ -265,7 +266,7 @@ OWI.controller('HeroesCtrl', ["$scope", "$rootScope", "$uibModal", "DataService"
CostAndTotalService.recalculate();
resetCosts();
});

this.clearFilters = function() {
this.filters = {
selected: false,
Expand Down Expand Up @@ -417,8 +418,14 @@ OWI.controller("UpdateCtrl", ["$scope", "$rootScope", "DataService", "StorageSer

OWI.controller('SettingsCtrl', ["$rootScope", "$uibModalInstance", "StorageService", "DataService", function($rootScope, $uibModalInstance, StorageService, DataService) {
var vm = this;
$rootScope.languages = [
{ id: 'en_US', label: 'English US', img: '../resources/heroes/all/icons/united-states-of-america.png' },
{ id: 'de_DE', label: 'German', img: '../resources/heroes/all/icons/germany.png' },
{ id: 'fr_FR', label: 'French', img: '../resources/heroes/all/icons/france.png' }
];
var settings = StorageService.settings;
this.particles = settings['particles'];
$rootScope.langKey = $rootScope.languages.find(function(lang) { return lang.id === StorageService.getSetting('langKey'); });
this.hdVideos = settings['hdVideos'];
this.currentTheme = settings['currentTheme'];
this.showPreviews = settings['showPreviews'];
Expand Down Expand Up @@ -531,4 +538,10 @@ OWI.controller('SettingsCtrl', ["$rootScope", "$uibModalInstance", "StorageServi
StorageService.setData(DataService.checked);
$rootScope.$emit('selectAll');
};

this.changeLanguage = function(langKey) {
this.langKey = langKey;
StorageService.setSetting('langKey', langKey);
location.reload();
};
}]);
25 changes: 24 additions & 1 deletion js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ OWI.factory("StorageService", function() {
settings: {},
defaultSettings: {
particles: true,
langKey: 'en_US',
showPreviews: true,
hdVideos: false,
currentTheme: 'standard',
Expand Down Expand Up @@ -56,6 +57,28 @@ OWI.factory("DataService", ["$http", "$q", "StorageService", function($http, $q,
out.checked[hero] = {"skins":{},"emotes":{},"intros":{},"sprays":{},"voicelines":{},"poses":{},"icons":{}};
}

// Use itemnames as translation key
Object.keys(data.events).forEach(function(event) {
var items = data.events[event].items;
Object.keys(items).forEach(function(type) {
items[type].forEach(function(item) {
var langKey = event + '.' + type + '.' + item.id;
item.name = langKey;
//item.langKey = langKey; //TODO: later use this?
});
});
});
Object.keys(data.heroes).forEach(function(hero) {
var items = data.heroes[hero].items;
Object.keys(items).forEach(function(type) {
items[type].forEach(function(item) {
var langKey = hero + '.' + type + '.' + item.id;
item.name = langKey;
//item.langKey = langKey; //TODO: later use this?
});
});
});

Object.assign(out.checked, storedData);
Object.assign(service, out, data);
setTimeout(function() {
Expand Down Expand Up @@ -299,7 +322,7 @@ OWI.factory("ImageLoader", ["$q", "$document", function($q, $document) {
}, 75);
return;
}

var nextImage = service.images.shift();
if (nextImage) {
service.requests++;
Expand Down
6 changes: 6 additions & 0 deletions js/vendor/angular-translate-loader-static-files.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions js/vendor/angular-translate.min.js

Large diffs are not rendered by default.

Loading