Skip to content

Commit

Permalink
Added additional translation labels and bootstraped JSON i18n to HTML…
Browse files Browse the repository at this point in the history
… report.
  • Loading branch information
allinurl committed Apr 8, 2017
1 parent c9ebfc7 commit 095b93c
Show file tree
Hide file tree
Showing 17 changed files with 1,087 additions and 504 deletions.
441 changes: 315 additions & 126 deletions po/fr.po

Large diffs are not rendered by default.

401 changes: 296 additions & 105 deletions po/goaccess.pot

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ window.GoAccess = window.GoAccess || {
this.AppUIData = (this.opts || {}).uiData || {}; // holds panel definitions
this.AppData = (this.opts || {}).panelData || {}; // hold raw data
this.AppWSConn = (this.opts || {}).wsConnection || {}; // WebSocket connection
this.i18n = (this.opts || {}).i18n || {}; // i18n report labels
this.AppPrefs = {
'theme': 'darkBlue',
'perPage': 7,
Expand Down Expand Up @@ -543,6 +544,7 @@ GoAccess.Nav = {
o['perPage' + this.getPerPage()] = true;
o['autoHideTables'] = GoAccess.Tables.autoHideTables();
o['showTables'] = GoAccess.Tables.showTables();
o['labels'] = GoAccess.i18n;

$('.nav-list').innerHTML = GoAccess.AppTpls.Nav.opts.render(o);
$('nav').classList.toggle('active');
Expand All @@ -554,6 +556,7 @@ GoAccess.Nav = {
$('.nav-list').innerHTML = GoAccess.AppTpls.Nav.menu.render({
'nav': this.getItems(),
'overall': window.location.hash.substr(1) == '',
'labels': GoAccess.i18n,
});
$('nav').classList.toggle('active');
this.events();
Expand Down Expand Up @@ -669,7 +672,7 @@ GoAccess.Panels = {
this.setChartSelection(ui, prefs);
this.setPlotSelection(ui, prefs);
this.setColSelection(ui.items, prefs);
return ui;
return GoAccess.Util.merge(ui, {'labels': GoAccess.i18n});
},

renderOpts: function (panel) {
Expand Down Expand Up @@ -737,7 +740,9 @@ GoAccess.Panels = {
// per panel wrapper
var box = document.createElement('div');
box.id = 'panel-' + panel;
box.innerHTML = GoAccess.AppTpls.Panels.wrap.render(ui);
box.innerHTML = GoAccess.AppTpls.Panels.wrap.render(GoAccess.Util.merge(ui, {
'labels': GoAccess.i18n
}));
col.appendChild(box);

// Remove pagination if not enough data for the given panel
Expand Down Expand Up @@ -1692,6 +1697,7 @@ GoAccess.App = {
// Init app
window.onload = function () {
GoAccess.initialize({
'i18n': window.json_i18n,
'uiData': window.user_interface,
'panelData': window.json_data,
'wsConnection': window.connection || null,
Expand Down
48 changes: 24 additions & 24 deletions resources/tpls.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ <h4 class="value"><span title="{{title}}">{{value}}</span>{{#label}}<small> {{la
<!-- TPL Panel Options DropDown -->
<script id="tpl-panel-opts" type="text/template">
<li class="dropdown-header">Charts Options</li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart="{{showChart}}"><i class="fa fa-{{#showChart}}check-{{/showChart}}square-o"></i> Chart</a></li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart="{{showChart}}"><i class="fa fa-{{#showChart}}check-{{/showChart}}square-o"></i> {{labels.chart}}</a></li>

{{#plot.length}}
<li class="dropdown-header">Type</li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart-type="area-spline"><i class="fa fa-circle{{^area-spline}}-o{{/area-spline}}"></i> Area Spline</a></li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart-type="bar"><i class="fa fa-circle{{^bar}}-o{{/bar}}"></i> Bar</a></li>
<li class="dropdown-header">Plot Metric</li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart-type="area-spline"><i class="fa fa-circle{{^area-spline}}-o{{/area-spline}}"></i> {{labels.area_spline}}</a></li>
<li><a href="javascript:void(0);" data-panel="{{id}}" data-chart-type="bar"><i class="fa fa-circle{{^bar}}-o{{/bar}}"></i> {{labels.bar}}</a></li>
<li class="dropdown-header">{{labels.plot_metric}}</li>
{{#plot}}
<li><a href="javascript:void(0);" data-panel="{{id}}" data-plot="{{className}}" class="panel-plot-{{className}}"><i class="fa fa-circle{{^selected}}-o{{/selected}}"></i> {{label}}</a></li>
{{/plot}}
{{/plot.length}}

<li class="dropdown-header">Table Columns</li>
<li class="dropdown-header">{{labels.table_columns}}</li>
{{#items}}
<li><a href="javascript:void(0);" data-panel="{{id}}" data-metric="{{key}}"><i class="fa fa-{{^hide}}check-{{/hide}}square-o"></i> {{label}}</a></li>
{{/items}}
Expand All @@ -115,7 +115,7 @@ <h5 class="pull-left visible-xs hidden-sm hidden-md hidden-lg gheader" id="{{id}
<div class="panel-plot-wrap">
<div class="dropdown">
<button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" data-panel="{{id}}">
<i class="fa fa-gear"></i> Panel Options <span class="fa fa-caret-down"></span>
<i class="fa fa-gear"></i> {{labels.panel_opts}} <span class="fa fa-caret-down"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right panel-opts-{{id}}">
</ul>
Expand Down Expand Up @@ -149,12 +149,12 @@ <h5 class="pull-left visible-xs hidden-sm hidden-md hidden-lg gheader" id="{{id}

<ul class="pagination pagination-sm pull-left">
<li class="disabled">
<a class="panel-prev" href="javascript:void(0);" aria-label="Previous" data-panel="{{id}}">
<a class="panel-prev" href="javascript:void(0);" aria-label="{{labels.previous}}" data-panel="{{id}}" title="{{labels.previous}}">
<i class="fa fa-chevron-left"></i>
</a>
</li>
<li>
<a class="panel-next" href="javascript:void(0);" aria-label="Next" data-panel="{{id}}">
<a class="panel-next" href="javascript:void(0);" aria-label="{{labels.next}}" data-panel="{{id}}" title="{{labels.next}}">
<i class="fa fa-chevron-right"></i>
</a>
</li>
Expand All @@ -172,30 +172,30 @@ <h5 class="pull-left visible-xs hidden-sm hidden-md hidden-lg gheader" id="{{id}
<div class="powered hidden-xs hidden-sm">by <a href="https://goaccess.io/">GoAccess</a> and <a href="http://gwsocket.io/">GWSocket</a></div>
</script>
<script id="tpl-nav-menu" type="text/template">
<h3>Panels</h3>
<h3>{{labels.panels}}</h3>
<ul>
<li {{#overall}}class="active"{{/overall}}><a href="#"><i class="fa fa-bar-chart"></i> Overall Analyzed Requests</a></li>
<li {{#overall}}class="active"{{/overall}}><a href="#"><i class="fa fa-bar-chart"></i> {{labels.thead}}</a></li>
{{#nav}}
<li {{#current}}class="active"{{/current}}><a href="#{{key}}"><i class="fa fa-{{icon}}"></i> {{head}}</a></li>
{{/nav}}
</ul>
</script>
<script id="tpl-nav-opts" type="text/template">
<h3><i class="fa fa-hashtag"></i> Theme</h3>
<h3><i class="fa fa-hashtag"></i> {{labels.theme}}</h3>
<ul>
<li {{#darkGray}}class="active"{{/darkGray}}>
<a href="javascript:void(0);" class="theme-dark-gray"><i class="fa fa-circle{{^darkGray}}-o{{/darkGray}}"></i> Dark Gray</a>
<a href="javascript:void(0);" class="theme-dark-gray"><i class="fa fa-circle{{^darkGray}}-o{{/darkGray}}"></i> {{labels.dark_gray}}</a>
</li>
<li {{#bright}}class="active"{{/bright}}>
<a href="javascript:void(0);" class="theme-bright"><i class="fa fa-circle{{^bright}}-o{{/bright}}"></i> Bright</a>
<a href="javascript:void(0);" class="theme-bright"><i class="fa fa-circle{{^bright}}-o{{/bright}}"></i> {{labels.bright}}</a>
</li>
<li {{#darkBlue}}class="active"{{/darkBlue}}>
<a href="javascript:void(0);" class="theme-dark-blue"><i class="fa fa-circle{{^darkBlue}}-o{{/darkBlue}}"></i> Dark Blue</a>
<a href="javascript:void(0);" class="theme-dark-blue"><i class="fa fa-circle{{^darkBlue}}-o{{/darkBlue}}"></i> {{labels.dark_blue}}</a>
</li>
</ul>
<h3><i class="fa fa-list-alt"></i> Panels</h3>
<h3><i class="fa fa-list-alt"></i> {{labels.panels}}</h3>
<ul class="perpage-wrap">
<li class="dropdown-header"><i class="fa fa-list"></i> Items Per Page</li>
<li class="dropdown-header"><i class="fa fa-list"></i> {{labels.items_per_page}}</li>
<li {{#perPage5}}class="active"{{/perPage5}}>
<a href="javascript:void(0);" data-perpage="5"><i class="fa fa-circle{{^perPage5}}-o{{/perPage5}}"></i> 5</a>
</li>
Expand All @@ -211,28 +211,28 @@ <h3><i class="fa fa-list-alt"></i> Panels</h3>
<li {{#perPage20}}class="active"{{/perPage20}}>
<a href="javascript:void(0);" data-perpage="20"><i class="fa fa-circle{{^perPage20}}-o{{/perPage20}}"></i> 20</a>
</li>
<li class="dropdown-header"><i class="fa fa-table"></i> Tables</li>
<li class="dropdown-header"><i class="fa fa-table"></i> {{labels.tables}}</li>
<li {{#showTables}}class="active"{{/showTables}}>
<a href="javascript:void(0);" data-show-tables="1"><i class="fa fa-{{#showTables}}check-{{/showTables}}square-o"></i> Display Tables</a>
<a href="javascript:void(0);" data-show-tables="1"><i class="fa fa-{{#showTables}}check-{{/showTables}}square-o"></i> {{labels.display_tables}}</a>
</li>
<li {{#autoHideTables}}class="active"{{/autoHideTables}}>
<a href="javascript:void(0);" data-autohide-tables="1" title="Automatically hide tables on small screen devices">
<i class="fa fa-{{#autoHideTables}}check-{{/autoHideTables}}square-o"></i> Auto-hide on small devices
<i class="fa fa-{{#autoHideTables}}check-{{/autoHideTables}}square-o"></i> {{labels.auto_hide_small}}
</a>
</li>
</ul>
<h3><i class="fa fa-th-large"></i> Layout</h3>
<h3><i class="fa fa-th-large"></i> {{labels.layout}}</h3>
<ul>
<li {{#horizontal}}class="active"{{/horizontal}}>
<a href="javascript:void(0);" class="layout-horizontal"><i class="fa fa-circle{{^horizontal}}-o{{/horizontal}}"></i> Horizontal</a>
<a href="javascript:void(0);" class="layout-horizontal"><i class="fa fa-circle{{^horizontal}}-o{{/horizontal}}"></i> {{labels.horizontal}}</a>
</li>
<li {{#vertical}}class="active"{{/vertical}}>
<a href="javascript:void(0);" class="layout-vertical"><i class="fa fa-circle{{^vertical}}-o{{/vertical}}"></i> Vertical</a>
<a href="javascript:void(0);" class="layout-vertical"><i class="fa fa-circle{{^vertical}}-o{{/vertical}}"></i> {{labels.vertical}}</a>
</li>
</ul>
<h3><i class="fa fa-cog"></i> File Options</h3>
<h3><i class="fa fa-cog"></i> {{labels.file_opts}}</h3>
<ul>
<li><a href="javascript:void(0);" class="export-json"><i class="fa fa-code"></i> Export as JSON</a></li>
<li><a href="javascript:void(0);" class="export-json"><i class="fa fa-code"></i> {{labels.export_json}}</a></li>
</ul>
</script>

Expand Down
14 changes: 8 additions & 6 deletions src/commons.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
#include <unistd.h>

#include "commons.h"

#include "error.h"
#include "labels.h"
#include "settings.h"
#include "util.h"
#include "xmalloc.h"
Expand Down Expand Up @@ -107,11 +109,11 @@ void
display_storage (void)
{
#ifdef TCB_BTREE
fprintf (stdout, "Built using Tokyo Cabinet On-Disk B+ Tree.\n");
fprintf (stdout, "%s\n", BUILT_WITH_TCBTREE);
#elif TCB_MEMHASH
fprintf (stdout, "Built using Tokyo Cabinet On-Memory Hash database.\n");
fprintf (stdout, "%s\n", BUILT_WITH_TCMEMHASH);
#else
fprintf (stdout, "Built using the default On-Memory Hash database.\n");
fprintf (stdout, "%s\n", BUILT_WITH_DEFHASH);
#endif
}

Expand All @@ -122,8 +124,8 @@ display_default_config_file (void)
char *path = get_config_file_path ();

if (!path) {
fprintf (stdout, "No default config file found.\n");
fprintf (stdout, "You may specify one with `-p /path/goaccess.conf`\n");
fprintf (stdout, "%s\n", ERR_NODEF_CONF_FILE);
fprintf (stdout, "%s `-p /path/goaccess.conf`\n", ERR_NODEF_CONF_FILE_DESC);
} else {
fprintf (stdout, "%s\n", path);
free (path);
Expand All @@ -135,7 +137,7 @@ void
display_version (void)
{
fprintf (stdout, "GoAccess - %s.\n", GO_VERSION);
fprintf (stdout, "For more details visit: http://goaccess.io\n");
fprintf (stdout, "%s: http://goaccess.io\n", INFO_MORE_INFO);
fprintf (stdout, "Copyright (C) 2009-2016 by Gerardo Orellana\n");
}

Expand Down
3 changes: 2 additions & 1 deletion src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <unistd.h>

#include "error.h"
#include "labels.h"
#include "parser.h"

static FILE *access_log;
Expand Down Expand Up @@ -171,7 +172,7 @@ sigsegv_handler (int sig)
#endif

fprintf (fp, "==%d==\n", pid);
fprintf (fp, "==%d== Please report it by opening an issue on GitHub:\n", pid);
fprintf (fp, "==%d== %s:\n", pid, ERR_PLEASE_REPORT);
fprintf (fp, "==%d== https://github.com/allinurl/goaccess/issues\n\n", pid);
exit (EXIT_FAILURE);
}
Expand Down
4 changes: 2 additions & 2 deletions src/gdashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ render_total_label (WINDOW * win, GDashModule * data, int y,
total = data->holder_size;
ht_size = data->ht_size;

s = xmalloc (snprintf (NULL, 0, "Total: %d/%d", total, ht_size) + 1);
s = xmalloc (snprintf (NULL, 0, "%s: %d/%d", GEN_TOTAL, total, ht_size) + 1);
getmaxyx (win, win_h, win_w);
(void) win_h;

sprintf (s, "Total: %d/%d", total, ht_size);
sprintf (s, "%s: %d/%d", GEN_TOTAL, total, ht_size);
draw_header (win, s, "%s", y, win_w - strlen (s) - 2, win_w, func);
free (s);
}
Expand Down
4 changes: 2 additions & 2 deletions src/gkhash.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/**
/**
/**
* gkhash.c -- default hash table functions
* ______ ___
Expand Down Expand Up @@ -54,8 +56,6 @@ static khash_t (si32) *ht_agent_keys = NULL;
static khash_t (si32) *ht_unique_keys = NULL;
static khash_t (ss32) *ht_hostnames = NULL;
/* *INDENT-ON* */

/* Instantiate a new store */
static GKHashStorage *
new_gkhstorage (uint32_t size)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gwsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void
set_ready_state (void)
{
fprintf (stderr, "\33[2K\r");
fprintf (stderr, "WebSocket server ready to accept new client connections\n");
fprintf (stderr, "%s\n", INFO_WS_READY_FOR_CONN);
}

/* Open the named pipe where the websocket server writes to.
Expand Down
Loading

0 comments on commit 095b93c

Please sign in to comment.