Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added spec with nested translation

  • Loading branch information...
commit d9705fc23538021a01265698879a81cc47780d30 1 parent df8e3db
Guillaume Denis authored
View
23 test/constants.js
@@ -3,15 +3,26 @@ var vows = require('vows')
, i18n = require('../index')({ dir: './test/fixtures'}).load()
vows.describe('Translate constants').addBatch({
- 'when saying hello': {
- topic: 'hello',
+ 'when greeting someone': {
+ topic: 'greeting',
- 'in English, we get Hello': function(topic) {
- assert.equal(i18n.setLocale('en').t('hello'), 'Hello')
+ 'in English, we say Hello': function(topic) {
+ assert.equal(i18n.setLocale('en').t(topic), 'Hello')
},
- 'in French, we get Bonjour': function(topic) {
- assert.equal(i18n.setLocale('fr').t('hello'), 'Bonjour')
+ 'in French, we say Bonjour': function(topic) {
+ assert.equal(i18n.setLocale('fr').t(topic), 'Bonjour')
+ }
+ },
+ 'when greeting someone in the evening': {
+ topic: 'evening.greeting',
+
+ 'in English, we say Good evening': function(topic) {
+ assert.equal(i18n.setLocale('en').t(topic), 'Good evening')
+ },
+
+ 'in French, we say Bonsoir': function(topic) {
+ assert.equal(i18n.setLocale('fr').t(topic), 'Bonsoir')
}
}
}).export(module)
View
5 test/fixtures/en.json
@@ -1,5 +1,8 @@
{
"en": {
- "hello": "Hello"
+ "greeting": "Hello",
+ "evening": {
+ "greeting": "Good evening"
+ }
}
}
View
5 test/fixtures/fr.json
@@ -1,5 +1,8 @@
{
"fr": {
- "hello": "Bonjour"
+ "greeting": "Bonjour",
+ "evening": {
+ "greeting": "Bonsoir"
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.