Skip to content

Node.js based forum software built for the modern web

added icons to all h1s in admin panel languages tab in ACP each language now also has a "language.json"

Julian Lamcd6af45afb20
diff --git a/public/language/de/language.json b/public/language/de/language.json
new file mode 100644
index 0000000000..c54ded42e4
--- /dev/null
+++ b/public/language/de/language.json
@@ -0,0 +1,4 @@
+{
+ "name": "German",
+ "code": "de"
+}
\ No newline at end of file
diff --git a/public/language/en/language.json b/public/language/en/language.json
new file mode 100644
index 0000000000..c96e8e9f8e
--- /dev/null
+++ b/public/language/en/language.json
@@ -0,0 +1,4 @@
+{
+ "name": "English",
+ "code": "en"
+}
\ No newline at end of file
diff --git a/public/language/es/language.json b/public/language/es/language.json
new file mode 100644
index 0000000000..32e8b29aef
--- /dev/null
+++ b/public/language/es/language.json
@@ -0,0 +1,4 @@
+{
+ "name": "Spanish",
+ "code": "es"
+}
\ No newline at end of file
diff --git a/public/language/fr/language.json b/public/language/fr/language.json
new file mode 100644
index 0000000000..5d539de773
--- /dev/null
+++ b/public/language/fr/language.json
@@ -0,0 +1,4 @@
+{
+ "name": "French",
+ "code": "fr"
+}
\ No newline at end of file
diff --git a/public/src/forum/admin/languages.js b/public/src/forum/admin/languages.js
new file mode 100644
index 0000000000..44182e3a13
--- /dev/null
+++ b/public/src/forum/admin/languages.js
@@ -0,0 +1,5 @@
+define(['forum/admin/settings'], function(Settings) {
+ jQuery('document').ready(function() {
+ Settings.prepare();
+ });
+});
\ No newline at end of file
diff --git a/public/src/translator.js b/public/src/translator.js
index fb8f602006..0808bacff3 100644
--- a/public/src/translator.js
+++ b/public/src/translator.js
@@ -8,8 +8,7 @@
* 1. language en is hardcoded while system is developed. to switch language packs for now please edit DEFAULT_LANGUAGE
* b. need to write fallback system to default language if keys are missing (is this even necessary?)
* 2. recursion needed when parsing language keys (ex. topics:modal.delete.title), right now json is all one level deep
- * 3. server side settings for default language
- * 4. user side settings for preferred language
+ * 3. user side settings for preferred language
*
*/
diff --git a/public/templates/admin/categories.tpl b/public/templates/admin/categories.tpl
index 927b690220..06ae5a0804 100644
--- a/public/templates/admin/categories.tpl
+++ b/public/templates/admin/categories.tpl
@@ -1,6 +1,6 @@
<div class="categories">
- <h1>Categories</h1>
+ <h1><i class="fa fa-folder"></i> Categories</h1>
<hr />
<ul class="nav nav-pills">
diff --git a/public/templates/admin/database.tpl b/public/templates/admin/database.tpl
index 40feb65c12..0461fdb436 100644
--- a/public/templates/admin/database.tpl
+++ b/public/templates/admin/database.tpl
@@ -1,7 +1,7 @@
<!-- IF redis -->
-<h1>Redis</h1>
+<h1><i class="fa fa-hdd-o"></i> Redis</h1>
<hr />
<div id="admin-redis-info">
<span>Redis Version</span> <span class="text-right">{redis_version}</span><br/>
@@ -32,7 +32,7 @@
<!-- ENDIF redis -->
<!-- IF mongo -->
-<h1>Mongo</h1>
+<h1><i class="fa fa-hdd-o"></i> Mongo</h1>
<hr />
<div id="admin-redis-info">
diff --git a/public/templates/admin/events.tpl b/public/templates/admin/events.tpl
index 989bdaa7f3..43bad6d192 100644
--- a/public/templates/admin/events.tpl
+++ b/public/templates/admin/events.tpl
@@ -1,4 +1,4 @@
-<h1>Events</h1>
+<h1><i class="fa fa-calendar-o"></i> Events</h1>
<pre>
{eventdata}
diff --git a/public/templates/admin/facebook.tpl b/public/templates/admin/facebook.tpl
index 14c6202cda..19137f8500 100644
--- a/public/templates/admin/facebook.tpl
+++ b/public/templates/admin/facebook.tpl
@@ -1,4 +1,4 @@
-<h1>Facebook Social Authentication</h1>
+<h1><i class="fa fa-facebook-square"></i> Facebook Social Authentication</h1>
<hr />
<form>
diff --git a/public/templates/admin/gplus.tpl b/public/templates/admin/gplus.tpl
index 81cf11852c..d44041adee 100644
--- a/public/templates/admin/gplus.tpl
+++ b/public/templates/admin/gplus.tpl
@@ -1,4 +1,4 @@
-<h1>Google Accounts Social Authentication</h1>
+<h1><i class="fa fa-google-plus-square"></i> Google Accounts Social Authentication</h1>
<hr />
<form>
diff --git a/public/templates/admin/groups.tpl b/public/templates/admin/groups.tpl
index cfd067f477..fa23608102 100644
--- a/public/templates/admin/groups.tpl
+++ b/public/templates/admin/groups.tpl
@@ -1,4 +1,4 @@
-<h1>Groups</h1>
+<h1><i class="fa fa-group"></i> Groups</h1>
<hr />
@@ -7,7 +7,7 @@
<!-- BEGIN groups -->
<li data-gid="{groups.gid}">
<div class="row">
- <div class="col-lg-8">
+ <div class="col-lg-8">
<h2>{groups.name}</h2>
<p>{groups.description}</p>
<div class="btn-group">
diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl
index 7253ea07df..71dbdad29a 100644
--- a/public/templates/admin/header.tpl
+++ b/public/templates/admin/header.tpl
@@ -102,6 +102,7 @@
<li><a href="{relative_path}/admin/topics"><i class="fa fa-fw fa-book"></i> Topics</a></li>
<li><a href="{relative_path}/admin/themes"><i class="fa fa-fw fa-th"></i> Themes</a></li>
<li><a href="{relative_path}/admin/plugins"><i class="fa fa-fw fa-code-fork"></i> Plugins</a></li>
+ <li><a href="{relative_path}/admin/languages"><i class="fa fa-fw fa-comments-o"></i> Languages</a></li>
<li><a href="{relative_path}/admin/settings"><i class="fa fa-fw fa-cogs"></i> Settings</a></li>
<li><a href="{relative_path}/admin/database"><i class="fa fa-fw fa-hdd-o"></i> Database</a></li>
<li><a href="{relative_path}/admin/logger"><i class="fa fa-fw fa-th"></i> Logger</a></li>
diff --git a/public/templates/admin/languages.tpl b/public/templates/admin/languages.tpl
new file mode 100644
index 0000000000..107712c424
--- /dev/null
+++ b/public/templates/admin/languages.tpl
@@ -0,0 +1,24 @@
+
+<div class="languages">
+ <h1><i class="fa fa-comments-o"></i> Languages</h1>
+ <hr />
+ <p>
+ The following setting(s) determine the language settings for your NodeBB.
+ The default language determines the language settings for all users who
+ are visiting your NodeBB. Keep in mind that individual users may decide
+ to switch languages for their own accounts.
+ </p>
+
+ <form class="row">
+ <div class="form-group col-sm-6">
+ <label for="defaultLang">Default Language</label>
+ <select data-field="defaultLang" class="form-control">
+ <!-- BEGIN languages -->
+ <option value="{languages.code}">{languages.name}</option>
+ <!-- END languages -->
+ </select>
+ </div>
+ </form>
+</div>
+
+<button class="btn btn-lg btn-primary" id="save">Save</button>
\ No newline at end of file
diff --git a/public/templates/admin/logger.tpl b/public/templates/admin/logger.tpl
index 7366760b83..8739d80896 100644
--- a/public/templates/admin/logger.tpl
+++ b/public/templates/admin/logger.tpl
@@ -1,4 +1,4 @@
-<h1>Logger</h1>
+<h1><i class="fa fa-th"></i> Logger</h1>
<hr />
<h3>Logger Settings</h3>
diff --git a/public/templates/admin/motd.tpl b/public/templates/admin/motd.tpl
index 6c1725099f..896dc196df 100644
--- a/public/templates/admin/motd.tpl
+++ b/public/templates/admin/motd.tpl
@@ -1,5 +1,4 @@
-
-<h1>MOTD</h1>
+<h1><i class="fa fa-comment"></i> MOTD</h1>
<hr />
<div class="alert alert-warning motd">
<p>
diff --git a/public/templates/admin/plugins.tpl b/public/templates/admin/plugins.tpl
index 074d53f0d9..5a9d62d0fa 100644
--- a/public/templates/admin/plugins.tpl
+++ b/public/templates/admin/plugins.tpl
@@ -1,4 +1,4 @@
-<h1>Plugins</h1>
+<h1><i class="fa fa-code-fork"></i> Plugins</h1>
<ul class="plugins">
<!-- BEGIN plugins -->
diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl
index fcb2114ce9..b5fef202c8 100644
--- a/public/templates/admin/settings.tpl
+++ b/public/templates/admin/settings.tpl
@@ -1,4 +1,4 @@
-<h1>Settings</h1>
+<h1><i class="fa fa-cogs"></i> Settings</h1>
<hr />
<h3>General Settings</h3>
@@ -128,7 +128,7 @@
<form>
<h3>Web Crawler Settings</h3>
<div class="alert alert-warning">
- <strong>Custom Robots.txt <small>Leave blank for default</small></strong><br />
+ <strong>Custom Robots.txt <small>Leave blank for default</small></strong><br />
<textarea class="form-control" data-field="robots.txt"></textarea>
</div>
</form>
diff --git a/public/templates/admin/themes.tpl b/public/templates/admin/themes.tpl
index bcc5e6a1e7..07b90b4bef 100644
--- a/public/templates/admin/themes.tpl
+++ b/public/templates/admin/themes.tpl
@@ -1,4 +1,4 @@
-<h1>Themes</h1>
+<h1><i class="fa fa-th"></i> Themes</h1>
<hr />
<h3>Custom Themes</h3>
diff --git a/public/templates/admin/topics.tpl b/public/templates/admin/topics.tpl
index aad36e206b..050b74b3b0 100644
--- a/public/templates/admin/topics.tpl
+++ b/public/templates/admin/topics.tpl
@@ -1,4 +1,4 @@
-<h1>Topics</h1>
+<h1><i class="fa fa-book"></i> Topics</h1>
<hr />
diff --git a/public/templates/admin/twitter.tpl b/public/templates/admin/twitter.tpl
index fb826a37bc..86dd5ccd94 100644
--- a/public/templates/admin/twitter.tpl
+++ b/public/templates/admin/twitter.tpl
@@ -1,4 +1,4 @@
-<h1>Twitter Social Authentication</h1>
+<h1><i class="fa fa-twitter-square"></i> Twitter Social Authentication</h1>
<hr />
<form>
diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl
index 71a802b4a8..4dcf4d0b85 100644
--- a/public/templates/admin/users.tpl
+++ b/public/templates/admin/users.tpl
@@ -1,4 +1,4 @@
-<h1>Users</h1>
+<h1><i class="fa fa-user"></i> Users</h1>
<button id="createUser" class="btn btn-primary">Create User</button>
<a target="_blank" href="/admin/users/csv" class="btn btn-primary">Download CSV</a>
diff --git a/public/templates/config.json b/public/templates/config.json
index 0fb31a1c30..f2ce55afa8 100644
--- a/public/templates/config.json
+++ b/public/templates/config.json
@@ -9,6 +9,7 @@
"^admin/index.*": "admin/index",
"^admin/themes.*": "admin/themes",
"^admin/plugins/?$": "admin/plugins",
+ "^admin/languages/?$": "admin/languages",
"^admin/settings.*": "admin/settings",
"^admin/twitter.*": "admin/twitter",
"^admin/facebook.*": "admin/facebook",
diff --git a/src/languages.js b/src/languages.js
new file mode 100644
index 0000000000..3ba42b3b6e
--- /dev/null
+++ b/src/languages.js
@@ -0,0 +1,51 @@
+var fs = require('fs'),
+ path = require('path'),
+ async = require('async'),
+
+ Languages = {};
+
+Languages.list = function(callback) {
+ var languagesPath = path.join(__dirname, '../public/language'),
+ languages = [];
+
+ fs.readdir(languagesPath, function(err, files) {
+ async.each(files, function(folder, next) {
+ fs.stat(path.join(languagesPath, folder), function(err, stat) {
+ if (!err) {
+ if (stat.isDirectory()) {
+ var configPath = path.join(languagesPath, folder, 'language.json');
+ fs.exists(configPath, function(exists) {
+ if (exists) {
+ fs.readFile(configPath, function(err, stream) {
+ languages.push(JSON.parse(stream.toString()));
+ next();
+ });
+ } else {
+ next();
+ }
+ });
+ } else {
+ next();
+ }
+ } else {
+ next();
+ }
+ });
+ }, function(err) {
+ // Float "en" to the top
+ languages = languages.sort(function(a, b) {
+ if (a.code === 'en') {
+ return -1;
+ } else if (b.code === 'en') {
+ return 1;
+ } else {
+ return 0;
+ }
+ });
+
+ callback(err, languages);
+ });
+ });
+};
+
+module.exports = Languages;
\ No newline at end of file
diff --git a/src/routes/admin.js b/src/routes/admin.js
index 8577e8aae3..3b07dd83f5 100644
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@ -11,11 +11,10 @@ var nconf = require('nconf'),
categories = require('./../categories'),
meta = require('../meta'),
plugins = require('../plugins'),
+ Languages = require('../languages'),
events = require('./../events'),
utils = require('./../../public/src/utils.js');
-
-
(function (Admin) {
Admin.isAdmin = function (req, res, next) {
user.isAdministrator((req.user && req.user.uid) ? req.user.uid : 0, function (err, isAdmin) {
@@ -57,9 +56,9 @@ var nconf = require('nconf'),
(function () {
var routes = [
'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
- 'twitter', 'facebook', 'gplus', 'database', 'events', 'motd', 'groups', 'plugins', 'logger',
- 'users/latest', 'users/sort-posts', 'users/sort-reputation',
- 'users/search'
+ 'twitter', 'facebook', 'gplus', 'database', 'events', 'motd', 'groups', 'plugins',
+ 'languages', 'logger',
+ 'users/latest', 'users/sort-posts', 'users/sort-reputation', 'users/search'
];
for (var i = 0, ii = routes.length; i < ii; i++) {
@@ -384,6 +383,14 @@ var nconf = require('nconf'),
});
});
+ app.get('/languages', function(req, res) {
+ Languages.list(function(err, languages) {
+ res.send(200, {
+ languages: languages
+ });
+ });
+ });
+
app.get('/settings', function (req, res) {
res.json(200, {});
});
diff --git a/src/routes/debug.js b/src/routes/debug.js
index 8a4d0e54eb..147df9d13c 100644
--- a/src/routes/debug.js
+++ b/src/routes/debug.js
@@ -80,14 +80,6 @@ var DebugRoute = function(app) {
});
app.get('/test', function(req, res) {
- var Emailer = require('../emailer');
- Emailer.send('welcome', 1, {
- username: 'test',
- subject: 'this is a subject',
- site_title: 'derp',
- confirm_link: 'linkylink'
- });
-
res.send();
});
});