Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
feat(service): introduce versionInfo function
Browse files Browse the repository at this point in the history
docs(guide): new versionInfo function
chore(grunt): grunt task for version inclusion
  • Loading branch information
tspaeth authored and knalli committed Sep 17, 2014
1 parent 2d8b302 commit e37d89c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,17 @@ module.exports = function (grunt) {
src: ['docs/content/guide/<%= language %>/*.ngdoc'],
title: 'Guide'
}
},

version: {
options: {
prefix: 'var version\\s+=\\s+[\'"]'
},
defaults: {
src: ['<%= concat.core.dest %>']
}
}

});


Expand Down Expand Up @@ -528,6 +538,7 @@ module.exports = function (grunt) {
grunt.registerTask('build:core', [
'jshint:core',
'concat:core',
'version',
'ngmin:core',
'concat:banner_core',
'uglify:core'
Expand Down
10 changes: 10 additions & 0 deletions docs/content/guide/de/03_using-translate-service.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ Dabei muss jedoch beachtet werden, dass der Service immer ein Objekt mit allen
Übersetzung (oder sogar alle) nicht übersetzt werden konnten. Eine mögliche
Fehlerbehandlung muss von Deiner Seite aus geschehen.

## angular-translate Versionsinformationen
Für einige Anwendungen mag es sinnvoll sein, die eingesetzte Version im "Über uns"-Bereich o.ä. anzuzeigen.
Damit dieses problemlos möglich ist, beinhaltet angular-translate eine Funktion, die sehr einfach verwendet werden
kann und die aktuelle Modulversion zurückgibt:

<pre>
$translate.versionInfo();
// returns e.g. "2.1.0"
</pre>

## Dinge die berücksichtigt werden sollten
Bitte beachte dass `$translate` Service kein Two-Way Data-Binding unterstützt.
`$translate` Service arbeitet asynchron, dass bedeteut aber nicht, dass er informiert
Expand Down
10 changes: 10 additions & 0 deletions docs/content/guide/en/03_using-translate-service.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ However, the service will always return an object containing translations -- reg
a translation (or even all of them) has failed. When requesting multiple translations
in one request, it is up to you to deal with the result.

## angular-translate library version information
As it may be useful for some "About" information in your application, we provide you a convenience
function to display or use the installed library version information.

Just call it this way:
<pre>
$translate.versionInfo();
// returns e.g. "2.1.0"
</pre>

## Things to keep in mind
Please keep in mind that the usage of the `$translate` service doesn't provide a two-way
data binding default! `$translate` service works asynchronously, which means
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"express": "~3.2.4",
"grunt-contrib-clean": "~0.5.0",
"load-grunt-tasks": "~0.2.0",
"grunt-ngdocs": "~0.1.11"
"grunt-ngdocs": "~0.1.11",
"grunt-version": "~0.3.0"
}
}
15 changes: 15 additions & 0 deletions src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
$postCompilingEnabled = false,
NESTED_OBJECT_DELIMITER = '.';

var version = 'x.y.z';

// tries to determine the browsers locale
var getLocale = function () {
Expand Down Expand Up @@ -1626,6 +1627,20 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
return result;
};

/**
* @ngdoc function
* @name pascalprecht.translate.$translate#versionInfo
* @methodOf pascalprecht.translate.$translate
*
* @description
* Returns the current version information for the angular-translate library
*
* @return {string} angular-translate version
*/
$translate.versionInfo = function () {
return version;
};

if ($loaderFactory) {

// If at least one async loader is defined and there are no
Expand Down

0 comments on commit e37d89c

Please sign in to comment.