summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-09-16 17:39:32 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-09-16 17:39:32 +0200
commit2937a633de8f54d0f5f20f8ced6e8914da40d312 (patch)
treefaf12c9d5e837e2c3e9e50388a6d60e1071b05d7
parentb36134664907e195278ab73c5afc0f42e7918df6 (diff)
also translate title, fix #350
-rw-r--r--CHANGELOG1
-rw-r--r--js/app/controllers/feedcontroller.coffee4
-rw-r--r--js/app/directives/translate.coffee32
-rw-r--r--js/public/app.js44
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee4
-rw-r--r--templates/main.php2
6 files changed, 82 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 963ddeabb..ba4f9df01 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ owncloud-news (1.602)
* Added ThemeRepublic.net Enhancer
* Remove unsigned from articles_per_update column to not fail with a weird error
* Manually convert &apos; to ' in title and author fields of articles because its not build into PHP
+* Fix localisation of app name in tab title
owncloud-news (1.601)
* Remove Google Reader import
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 415072579..07fb22238 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -56,9 +56,9 @@ ActiveFeed, FeedType, $window) ->
# and it has nothing to do with the body structure
if count > 0
titleCount = @_unreadCountFormatter(count)
- title = 'News (' + titleCount + ') | ownCloud'
+ title = @_$scope.translations.appName + ' (' + titleCount + ') | ownCloud'
else
- title = 'News | ownCloud'
+ title = @_$scope.translations.appName + ' | ownCloud'
# only update title when it changed to prevent highlighting the
# tab
diff --git a/js/app/directives/translate.coffee b/js/app/directives/translate.coffee
new file mode 100644
index 000000000..c3e2dfd47
--- /dev/null
+++ b/js/app/directives/translate.coffee
@@ -0,0 +1,32 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+###
+
+
+# Binds translated values to scope and hides the element
+angular.module('News').directive 'newsTranslate', ->
+ directive =
+ restrict: 'E'
+ link: (scope, element, attributes) ->
+ $element = $(element)
+ scope.translations or= scope.translations
+ scope.translations[attributes.key] = $element.text()
+ $element.remove()
diff --git a/js/public/app.js b/js/public/app.js
index eab057778..751834832 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -503,6 +503,46 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ angular.module('News').directive('newsTranslate', function() {
+ var directive;
+ return directive = {
+ restrict: 'E',
+ link: function(scope, element, attributes) {
+ var $element;
+ $element = $(element);
+ scope.translations || (scope.translations = scope.translations);
+ scope.translations[attributes.key] = $element.text();
+ return $element.remove();
+ }
+ };
+ });
+
+}).call(this);
+
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
angular.module('News').directive('undoNotification', [
'$rootScope', '$timeout', 'Config', function($rootScope, $timeout, Config) {
return function(scope, elm, attr) {
@@ -646,9 +686,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
count = _this._subscriptionsBusinessLayer.getUnreadCount(0);
if (count > 0) {
titleCount = _this._unreadCountFormatter(count);
- title = 'News (' + titleCount + ') | ownCloud';
+ title = _this._$scope.translations.appName + ' (' + titleCount + ') | ownCloud';
} else {
- title = 'News | ownCloud';
+ title = _this._$scope.translations.appName + ' | ownCloud';
}
if (_this._$window.document.title !== title) {
_this._$window.document.title = title;
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee
index 2d51000ea..13ce1bb44 100644
--- a/js/tests/controllers/feedcontrollerSpec.coffee
+++ b/js/tests/controllers/feedcontrollerSpec.coffee
@@ -79,6 +79,8 @@ describe 'FeedController', ->
it 'should set the window title to the total unread count', =>
+ @scope.translations =
+ appName: 'News'
expect(@$window.document.title).toBe('')
@scope.getTotalUnreadCount()
@@ -92,6 +94,8 @@ describe 'FeedController', ->
it 'should show 99+ if in window title when more than 99 unread count', =>
+ @scope.translations =
+ appName: 'News'
item = {id: 3, unreadCount: 1, faviconLink: 'test', url: 'hi'}
item1 = {id: 5, unreadCount: 999, faviconLink: 'test', url: 'his'}
@FeedModel.add(item)
diff --git a/templates/main.php b/templates/main.php
index 80cf5eb86..90d3896d1 100644
--- a/templates/main.php
+++ b/templates/main.php
@@ -34,8 +34,8 @@ if($version[0] > 5 || ($version[0] >= 5 && $version[1] >= 80)) {
<a href="#"><?php p($l->t('Undo deletion of %s', '{{ getCaption() }}')); ?></a>
</div>
</div>
-
<div id="app-navigation" ng-controller="FeedController">
+ <news-translate key="appName"><?php p($l->t('News')); ?></news-translate>
<ul class="with-icon" data-id="0" droppable>
<?php print_unescaped($this->inc('part.addnew')) ?>