Skip to content

Commit bf99833

Browse files
authored
Merge pull request ninenine#32 from acardinale/master
Languages management
2 parents 6da3c35 + fece813 commit bf99833

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
var winston = require.main.require('winston');
44
var meta = require.main.require('./src/meta');
55

6+
var translator = module.parent.require('../public/src/modules/translator');
7+
68
var toRegExp = require('./lib/toRegExp');
79
var parseContent = require('./lib/parseContent');
810

@@ -95,11 +97,15 @@ var Beep = {
9597

9698
var titleMatch = postTitle && postTitle.match(Beep.illegal_words);
9799
if (titleMatch) {
98-
return callback(new Error('You may not use the word "' + titleMatch[0] + '" in your title.'));
100+
return translator.translate('[[beep:titleMatch.error, ' + titleMatch[0] + ']]', function(translated) {
101+
callback(new Error(translated));
102+
});
99103
}
100104
var contentMatch = postContent && postContent.match(Beep.illegal_words);
101105
if (contentMatch) {
102-
return callback(new Error('You may not use the word "' + contentMatch[0] + '" in your post.'));
106+
return translator.translate('[[beep:contentMatch.error, ' + contentMatch[0] + ']]', function(translated) {
107+
callback(new Error(translated));
108+
});
103109
}
104110

105111
callback(null, data);
@@ -147,7 +153,9 @@ var Beep = {
147153
});
148154

149155
if (match) {
150-
return callback(new Error('You may not use the word "' + match[0] + '" in your tags.'));
156+
return translator.translate('[[beep:tagMatch.error, ' + match[0] + ']]', function(translated) {
157+
callback(new Error(translated));
158+
});
151159
}
152160

153161
data.tags = data.tags.map(function (tag) {

languages/en_GB/beep.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"titleMatch.error": "You may not use the word \"%1\" in your title.",
3+
"contentMatch.error": "You may not use the word \"%1\" in your post.",
4+
"tagMatch.error": "You may not use the word \"%1\" in your tags."
5+
}

languages/it/beep.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"titleMatch.error": "Non puoi usare la parola \"%1\" nel titolo.",
3+
"contentMatch.error": "Non puoi usare la parola \"%1\" ne post.",
4+
"tagMatch.error": "Non puoi usare la parola \"%1\" nei tags."
5+
}

plugin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
{ "hook": "filter:config.get", "method": "appendConfig" },
2828

2929
{ "hook": "filter:messaging.getTeaser", "method": "messaging.getTeaser" }
30-
]
30+
],
31+
"languages": "languages",
32+
"defaultLang": "en_GB"
3133
}

0 commit comments

Comments
 (0)