Skip to content

Commit 271188b

Browse files
committed
Version 2.0.0
2 parents 638508f + fab1763 commit 271188b

File tree

17 files changed

+85
-22
lines changed

17 files changed

+85
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ When using `npm` the translation files will not be loaded eagerly any longer. Se
1212

1313
To make it work with `npm` the files have been translated to JavaScript, so if you use CoffeeScript you can require from the main directory and if you use JavaScript you would import/require from `build`.
1414

15-
Breaking change: Reactivity for the language and translations are no longer available. This used a Meteor functionality which is not available in a plain Node environment, which also consumed a lot of resources and many applications never used it. If this is a critical feature for somebody please open a ticket, this could be maybe implemented in a separate package.
15+
In theory this package can be used in any JavaScript project, but reactivity is only available within a Meteor environment.
1616

17-
The `examples` show different use cases:
17+
These `examples` show different use cases:
1818

1919
- meteorPackage: This is way it has been used in former versions as a meteor package.
2020
- meteorNpm: Use t9n as npm package within Meteor.

build/t9n.js

Lines changed: 34 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/meteorNpm/client/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</body>
99

1010
<template name="app">
11-
Lang: {{currentLang}}
1211
<h1>{{t9n 'hello' name='Meteor'}}</h1>
12+
<h3>Lang: {{currentLang}}</h3>
1313
{{t9n 'pun' subject='Fischer\'s Fritz' predicate='fischt' object='Fische' adverb='frische'}}
1414
<br/>
1515
<br/>

examples/meteorNpm/client/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ T9n.map('de', {
66
'hello': 'Hallo @{name}!',
77
'pun': '@{subject} @{predicate} @{adverb} @{object}. Frische @{object} @{predicate} @{subject}.',
88
});
9+
T9n.map('es', {
10+
'hello': 'Hola @{name}!',
11+
'pun': 'No anda bien en castellano eso de "@{subject} @{predicate} @{adverb} @{object}. Frische @{object} @{predicate} @{subject}".',
12+
});
913
T9n.setLanguage('de');
1014

1115
// as the template helper is not registered at this moment do it here
1216
Template.registerHelper('t9n', (x, params) => T9n.get(x, true, params.hash));
1317
Template.registerHelper('currentLang', () => T9n.getLanguage());
1418

1519
Template.app.events({
16-
'click button': () => T9n.setLanguage('es'), // no reactivity!
20+
'click button': () => T9n.setLanguage(flipLanguage()),
1721
});
22+
23+
const flipLanguage = () => T9n.getLanguage() === 'es' ? 'de' : 'es';
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
lang = 'de'
2+
T9n.setLanguage(lang)
3+
T9n.map lang, 'hello': 'Hallo @{name}!'
4+
T9n.map lang, 'pun': '@{subject} @{predicate} @{adverb} @{object}. Frische @{object} @{predicate} @{subject}.'
5+
T9n.map 'es', 'hello': 'Hola @{name}!'
6+
7+
Template.registerHelper 'currentLang', () => T9n.getLanguage()
8+
9+
Template.app.events
10+
'click button': => T9n.setLanguage flipLanguage()
11+
12+
13+
flipLanguage = => if T9n.getLanguage() is 'es' then 'de' else 'es'

examples/meteorPpackage/client/index.html renamed to examples/meteorPackage/client/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
</head>
55

66
<body>
7+
{{> app}}
8+
</body>
9+
10+
<template name="app">
711
<h1>{{t9n 'hello' name='Meteor'}}</h1>
12+
<h3>Lang: {{currentLang}}</h3>
813
{{t9n 'pun' subject='Fischer\'s Fritz' predicate='fischt' object='Fische' adverb='frische'}}
9-
</body>
14+
<br/>
15+
<br/>
16+
<button>{{t9n 'emailResetLink'}}</button>
17+
</template>

0 commit comments

Comments
 (0)