Skip to content

Commit

Permalink
Remove version from header's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
chleck committed Jan 19, 2013
1 parent 16c0037 commit 4f11896
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test/npm-debug.log
node_modules/
locale.*
TODO.md
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Plural forms for any language
* Simultaneous support of multiple languages
* Flexible placeholders
* Remote translation
* Deferred translation

## It's simple
---
Expand Down Expand Up @@ -44,7 +44,7 @@ See [locale-tools project](https://github.com/chleck/locale-tools "Tools for loc
- [Translation target](#translation-target)
- [Translation](#translation)
- [Strings format](#strings-format)
- [Remote translation](#remote-translation)
- [Deferred translation](#deferred-translation)

## Library import
---
Expand Down Expand Up @@ -107,15 +107,15 @@ new locale.i18n(target)
, where *target* (string or null) - 1) id of the target language, 2) empty string or 3) null.

Sets target language to base language if *target* is *''* (empty string).
Enables remote translation mode if *target* is *null*.
Enables deferred translation mode if *target* is *null*.

### Example:
```javascript
// Create translation object for Russian language
var i18n = new locale.i18n('ru');
// Create translation object for base language (no translation)
var i18n = new locale.i18n('');
// Create translation object for remote translation
// Create translation object for deferred translation
var i18n = new locale.i18n(null);
// And pull up __() function to the local scope
var __ = i18n.__;
Expand All @@ -138,7 +138,7 @@ to(target)
, where *target* (string or null) - 1) id of target language, 2) empty string or 3) null.

Sets target language to base language if *target* is *''* (empty string).
Switches i18n object to remote translation mode if *target* is *null*.
Switches i18n object to deferred translation mode if *target* is *null*.

### Example:
```javascript
Expand All @@ -147,7 +147,7 @@ locale.to('de');
// Create i18n object and set its target language to Russian
var i18n = new locale.i18n();
i18n.to('ru');
// Enable remote translation mode
// Enable deferred translation mode
i18n.to(null);
```
## Translation
Expand All @@ -169,7 +169,7 @@ __(phrase, object)
- *array* (Array) - array of args;
- *object* (object) - map of args.

Returns translated string or remote translation data (in case of remote translation target).
Returns translated string or deferred translation data (in case of deferred translation target).

### For plural form:
```javascript
Expand All @@ -186,7 +186,7 @@ __(phrase, n, object)
- *array* (Array) - array of args;
- *object* (object) - map of args.

Returns translated string or remote translation data (in case of remote translation target).
Returns translated string or deferred translation data (in case of deferred translation target).

### Example:
```javascript
Expand Down Expand Up @@ -218,12 +218,12 @@ __([
'%(login)s, you have %n unreaded messages in the "%(folder)s" folder.'
], 365, { login: 'Anonymous', folder: 'Spam' });

// Remote:
// Deferred:

// { __i18n: true, phrase: 'Hello!', n: undefined, args: {} }
__('Hello!');
```
See also: [Remote translation](#remote-translation).
See also: [Deferred translation](#deferred-translation).

## Strings format
---
Expand Down Expand Up @@ -325,16 +325,16 @@ __('%s%%', 40);
__('It\'s ## not a comment!);
```
## Remote translation
## Deferred translation
---
### Search for remote translation data in the *obj* and replace it by translated string:
### Search for deferred translation data in the *obj* and replace it by translated string:
```javascript
i18n.tr(obj)
```
, where *obj* (object) - object for translation.
### Remote translation data structure:
### Deferred translation data structure:
```
{
__i18n: true,
Expand All @@ -349,7 +349,7 @@ See also: [Creating i18n object](#creating-i18n-object).
```javascript
// Server:
// Create i18n object for the remote mode
// Create i18n object for the deferred mode
var i18n = new locale.i18n(null);
var __ = i18n.__;
submit({
Expand Down
3 changes: 1 addition & 2 deletions example/deferred.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
* # locale library usage examples: remote translation
* # locale library usage examples: deferred translation
*
* ## locale.js: i18n for Node.js and browser
*
* @author Dmitry A. Chleck <dmitrychleck@gmail.com>
* @version 1.1.0
* @url https://github.com/chleck/locale-js
*/

Expand Down
8 changes: 4 additions & 4 deletions example/i18n/ru.tr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
@ [1] remote.js (24:15)
@ [2] remote.js (26:17)
@ [1] deferred.js (24:15)
@ [2] deferred.js (26:17)
@ [3] translate.js (37:6)
@ [4] translate.js (39:6)
S Hello!
# [4] This is comment.
? Hello!
! Привет!

@ [1] remote.js (25:13)
@ [1] deferred.js (25:13)
P The following error occurred during processing:
? The following error occurred during processing:
? The following errors occurred during processing:
! Во время обработки возникла следующая ошибка:
! Во время обработки возникли следующие ошибки:
! Во время обработки возникли следующие ошибки:

@ [1] remote.js (26:31)
@ [1] deferred.js (26:31)
S Email %s is invalid. Please enter valid email.
? Email %s is invalid. Please enter valid email.
! Недопустимый email %s. Пожалуйста, введите правильный email.
Expand Down
1 change: 0 additions & 1 deletion example/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* ## locale.js: i18n for Node.js and browser
*
* @author Dmitry A. Chleck <dmitrychleck@gmail.com>
* @version 1.1.0
* @url https://github.com/chleck/locale-js
*/

Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* ## locale.js: i18n for Node.js and browser
*
* @author Dmitry A. Chleck <dmitrychleck@gmail.com>
* @version 1.1.0
* @url https://github.com/chleck/locale-js
*/

Expand Down
6 changes: 2 additions & 4 deletions lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* ## locale.js: i18n for Node.js and browser
*
* @author Dmitry A. Chleck <dmitrychleck@gmail.com>
* @version 1.1.0
* @url https://github.com/chleck/locale-js
*/

Expand Down Expand Up @@ -93,11 +92,11 @@ var locale = new function() {
a = a[0];
}
var json = { '__i18n': true, 'phrase': phrase, 'n': n, 'args': a };
// Check remote mode
// Check deferred mode
return to === null ? json : translate(json, to);
}

// # Translate remote objects
// # Translate deferred objects
this.tr = function(obj) {
if(typeof obj !== 'object') return;
for(var o in obj) {
Expand Down Expand Up @@ -139,7 +138,6 @@ var locale = new function() {
}
}
}
//return fill(result, args.args, args.n);
return sprintf(result, args.args, args.n);
}

Expand Down
9 changes: 4 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* ## locale.js: i18n for Node.js and browser
*
* @author Dmitry A. Chleck <dmitrychleck@gmail.com>
* @version 1.1.0
* @url https://github.com/chleck/locale-js
*/

Expand Down Expand Up @@ -36,7 +35,7 @@ describe('Test suite for locale library', function() {
i18n = new locale.i18n();
})

it('Create i18n object for remote translation', function() {
it('Create i18n object for deferred translation', function() {
i18n = new locale.i18n(null);
})

Expand Down Expand Up @@ -314,14 +313,14 @@ describe('Test suite for locale library', function() {

})

describe('Remote translation:', function() {
describe('Deferred translation:', function() {

it('Turn on remote translation mode', function() {
it('Turn on deferred translation mode', function() {
locale.to(null);
__ = locale.__;
})

it('Create object containing remote translation data', function() {
it('Create object containing deferred translation data', function() {
tmp = {
data: 'Some data...',
array: [ 1, 2, 3, 4, 5 ],
Expand Down

0 comments on commit 4f11896

Please sign in to comment.