feat: support *.properties resource files
This commit is contained in:
@@ -98,6 +98,27 @@ describe('koa-locales.test.js', function () {
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should use query locale: de on *.properties format', function (done) {
|
||||
request(app.callback())
|
||||
.get('/?locale=de')
|
||||
.expect({
|
||||
email: 'Emailde',
|
||||
hello: 'Hallo fengmk2, wie geht es dir heute?',
|
||||
message: 'Hallo fengmk2, wie geht es dir heute? Wie war dein 18.',
|
||||
empty: '',
|
||||
notexists_key: 'key not exists',
|
||||
empty_string: '',
|
||||
novalue: 'key %s ok',
|
||||
arguments3: '1 2 3',
|
||||
arguments4: '1 2 3 4',
|
||||
arguments5: '1 2 3 4 5',
|
||||
arguments6: '1 2 3 4 5. 6',
|
||||
values: 'foo bar foo bar {2} {100}',
|
||||
})
|
||||
.expect('Set-Cookie', /^locale=de; path=\/; expires=\w+/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should use query locale and change cookie locale', function (done) {
|
||||
request(app.callback())
|
||||
.get('/?locale=zh-CN')
|
||||
@@ -284,8 +305,8 @@ describe('koa-locales.test.js', function () {
|
||||
request(app.callback())
|
||||
.get('/?locale=')
|
||||
.expect({
|
||||
email: 'Email',
|
||||
hello: 'Hello fengmk2, how are you today?',
|
||||
email: '郵箱',
|
||||
hello: 'fengmk2,今天過得如何?',
|
||||
message: 'Hello fengmk2, how are you today? How was your 18.',
|
||||
empty: '',
|
||||
notexists_key: 'key not exists',
|
||||
|
||||
3
test/locales/de.properties
Normal file
3
test/locales/de.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
Email = Emailde
|
||||
"Hello %s, how are you today?" = "Hallo %s, wie geht es dir heute?"
|
||||
Hello %s, how are you today? How was your %s. = Hallo %s, wie geht es dir heute? Wie war dein %s.
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
'Email': '邮箱',
|
||||
Email: '邮箱',
|
||||
'Hello %s, how are you today?': '%s,今天过得如何?',
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
|
||||
"Email": "郵箱",
|
||||
"Hello %s, how are you today?": "%s,今天過得如何?"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user