Skip to content

Commit 1ff7976

Browse files
committed
Handle locales
1 parent 8df162e commit 1ff7976

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+13658
-56
lines changed

.tx/config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[main]
2+
host = https://www.transifex.com
3+
4+
[glpi-plugin-gantt.gantt-pot]
5+
file_filter = locales/<lang>.po
6+
source_file = locales/gantt.pot
7+
source_lang = en_GB
8+
type = PO

ajax/gantt.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
$p_target = $_POST["target"];
105105

106106
if ($p_item["type"] == "project" && $p_target["type"] != "project") {
107-
throw new \Exception(__("Target item must be of project type"));
107+
throw new \Exception(__("Target item must be of project type", 'gantt'));
108108
}
109109

110110
$item = new \GlpiPlugin\Gantt\Item();
@@ -137,7 +137,7 @@
137137

138138
// double check for safety..
139139
if ($p_item["type"] != "project") {
140-
throw new \Exception(__("Item must be of project type"));
140+
throw new \Exception(__("Item must be of project type", 'gantt'));
141141
}
142142

143143
$item = new \GlpiPlugin\Gantt\Item();
@@ -202,7 +202,7 @@
202202
$taskLink = new \ProjectTaskLink();
203203

204204
if ($taskLink->checkIfExist($_POST["taskLink"])) {
205-
throw new \Exception(__("Link already exist!"));
205+
throw new \Exception(__("Link already exist!", 'gantt'));
206206
}
207207

208208
$id = $taskLink->add($_POST["taskLink"]);

js/gantt-helper.js

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,31 @@ var GlpiGantt = (function() {
4949
break;
5050
}
5151

52+
gantt.i18n.setLocale(CFG_GLPI.language.substr(0, 2));
53+
5254
var formatFunc = gantt.date.date_to_str(parseDateFormat);
5355

5456
return {
5557
init: function($ID) {
5658

5759
var project_subtypes = [
58-
{ key: gantt.config.types.project, label: _n("Project", "Projects", 1) },
59-
{ key: gantt.config.types.task, label: _n("Task", "Tasks", 1) },
60-
{ key: gantt.config.types.milestone, label: __("Milestone") }
60+
{ key: gantt.config.types.project, label: _n("Project", "Projects", 1, 'gantt') },
61+
{ key: gantt.config.types.task, label: _n("Task", "Tasks", 1, 'gantt') },
62+
{ key: gantt.config.types.milestone, label: __("Milestone", 'gantt') }
6163
];
6264

6365
var task_subtypes = [
64-
{ key: gantt.config.types.task, label: _n("Task", "Tasks", 1) },
65-
{ key: gantt.config.types.milestone, label: __("Milestone") }
66+
{ key: gantt.config.types.task, label: _n("Task", "Tasks", 1, 'gantt') },
67+
{ key: gantt.config.types.milestone, label: __("Milestone", 'gantt') }
6668
];
6769

6870
var default_section = [
69-
{ name: "description", height: 70, map_to: "text", type: "textarea", focus: true, default_value: __("New project") },
71+
{ name: "description", height: 70, map_to: "text", type: "textarea", focus: true, default_value: __("New project", 'gantt') },
7072
{ name: "time", type: "duration", map_to: "auto" }
7173
];
7274

7375
var new_project_section = [
74-
{ name: "description", height: 70, map_to: "text", type: "textarea", focus: true, default_value: __("New project") },
76+
{ name: "description", height: 70, map_to: "text", type: "textarea", focus: true, default_value: __("New project", 'gantt') },
7577
{ name: "time", type: "duration", map_to: "auto" },
7678
{ name: "type", type: "radio", map_to: "type", options: project_subtypes, default_value: gantt.config.types.project }
7779
];
@@ -145,24 +147,24 @@ var GlpiGantt = (function() {
145147

146148
gantt.templates.tooltip_text = function(start, end, task) {
147149
var text = "<b><span class=\"capitalize\">" +
148-
task.type + ":</span></b> " + task.text + "<br/><b>" + __("Start date:") + "</b> " +
150+
task.type + ":</span></b> " + task.text + "<br/><b>" + __("Start date:", 'gantt') + "</b> " +
149151
gantt.templates.tooltip_date_format(start) +
150-
"<br/><b>" + __("End date:") + "</b> " + gantt.templates.tooltip_date_format(end) +
151-
"<br/><b>" + __("Progress:") + "</b> " + parseInt(task.progress * 100) + "%";
152+
"<br/><b>" + __("End date:", 'gantt') + "</b> " + gantt.templates.tooltip_date_format(end) +
153+
"<br/><b>" + __("Progress:", 'gantt') + "</b> " + parseInt(task.progress * 100) + "%";
152154
if (task.content && task.content.length > 0) {
153-
text += "<br/><b>" + __("Description:") + "</b><div style=\"padding-left:25px\">" + task.content + "</div>";
155+
text += "<br/><b>" + __("Description:", 'gantt') + "</b><div style=\"padding-left:25px\">" + task.content + "</div>";
154156
}
155157
if (task.comment && task.comment.length > 0) {
156-
text += "<br/><b>" + __("Comment:") + "</b><div style=\"padding-left:25px\">" + task.comment + "</div>";
158+
text += "<br/><b>" + __("Comment:", 'gantt') + "</b><div style=\"padding-left:25px\">" + task.comment + "</div>";
157159
}
158160
return text;
159161
};
160162

161163
// columns definition
162164
gantt.config.columns = [
163-
{ name: "text", label: __("Project / Task"), width: 290, tree: true, align: "left" },
164-
{ name: "start_date", label: __("Start date"), align: "left", width: 90 },
165-
{ name: "duration", label: __("Duration"), align: "center", width: 47 },
165+
{ name: "text", label: __("Project / Task", 'gantt'), width: 290, tree: true, align: "left" },
166+
{ name: "start_date", label: __("Start date", 'gantt'), align: "left", width: 90 },
167+
{ name: "duration", label: __("Duration", 'gantt'), align: "center", width: 47 },
166168
{ name: "add", align: "center" }
167169
];
168170

@@ -210,7 +212,7 @@ var GlpiGantt = (function() {
210212
},
211213
{
212214
unit: "week",
213-
format: __("Week #%s").replace('%s', '%W')
215+
format: __("Week #%s", 'gantt').replace('%s', '%W')
214216
}
215217
]
216218
},
@@ -321,7 +323,7 @@ var GlpiGantt = (function() {
321323
if (task.$new) {
322324
gantt.getLightboxSection("time").setValue(new Date());
323325
if (!isNaN(task.parent)) {
324-
gantt.getLightboxSection("description").setValue(__('New project'));
326+
gantt.getLightboxSection("description").setValue(__('New project', 'gantt'));
325327
}
326328
} else {
327329
if (gantt.getLightboxSection("type")) {
@@ -370,16 +372,16 @@ var GlpiGantt = (function() {
370372

371373
switch (parseInt(link.type)) {
372374
case parseInt(gantt.config.links.finish_to_start):
373-
linkTitle = __("Finish to Start: ");
375+
linkTitle = __("Finish to Start: ", 'gantt');
374376
break;
375377
case parseInt(gantt.config.links.finish_to_finish):
376-
linkTitle = __("Finish to Finish: ");
378+
linkTitle = __("Finish to Finish: ", 'gantt');
377379
break;
378380
case parseInt(gantt.config.links.start_to_start):
379-
linkTitle = __("Start to Start: ");
381+
linkTitle = __("Start to Start: ", 'gantt');
380382
break;
381383
case parseInt(gantt.config.links.start_to_finish):
382-
linkTitle = __("Start to Finish: ");
384+
linkTitle = __("Start to Finish: ", 'gantt');
383385
break;
384386
}
385387

@@ -388,12 +390,12 @@ var GlpiGantt = (function() {
388390
modal = gantt.modalbox({
389391
title: `<p class="gantt_cal_lsection" style="line-height:normal">${linkTitle}</p>`,
390392
text: `<div class="gantt_cal_lsection">
391-
<label>${__("Lag")} <input type="number" class="lag-input" /></label>
393+
<label>${__("Lag", 'gantt')} <input type="number" class="lag-input" /></label>
392394
</div>`,
393395
buttons: [
394-
{ label: __("Save"), css: "gantt_save_btn", value: "save" },
395-
{ label: __("Cancel"), css: "gantt_cancel_btn", value: "cancel" },
396-
{ label: __("Delete"), css: "gantt_delete_btn", value: "delete" }
396+
{ label: __("Save", 'gantt'), css: "gantt_save_btn", value: "save" },
397+
{ label: __("Cancel", 'gantt'), css: "gantt_cancel_btn", value: "cancel" },
398+
{ label: __("Delete", 'gantt'), css: "gantt_delete_btn", value: "delete" }
397399
],
398400
width: "500px",
399401
callback: function(result) {
@@ -515,7 +517,7 @@ var GlpiGantt = (function() {
515517
gantt.message.position = 'bottom';
516518
gantt.message({
517519
type: 'warning',
518-
text: __('Gantt mode: \'Readonly\''),
520+
text: __('Gantt mode: \'Readonly\'', 'gantt'),
519521
expire: -1
520522
});
521523
}
@@ -561,22 +563,22 @@ var GlpiGantt = (function() {
561563
var valid = true;
562564

563565
if (source.type == 'project' && target.type == 'project') {
564-
gantt.alert(__("Links between projects cannot be created."));
566+
gantt.alert(__("Links between projects cannot be created.", 'gantt'));
565567
valid = false;
566568
} else if (source.type == 'project' || target.type == 'project') {
567-
gantt.alert(__("Links between projects and tasks cannot be created."));
569+
gantt.alert(__("Links between projects and tasks cannot be created.", 'gantt'));
568570
valid = false;
569571
} else if (type == gantt.config.links.finish_to_start && target.start_date < source.end_date) {
570-
gantt.alert(__("Target task can't start before source task ends."));
572+
gantt.alert(__("Target task can't start before source task ends.", 'gantt'));
571573
valid = false;
572574
} else if (type == gantt.config.links.start_to_start && target.start_date < source.start_date) {
573-
gantt.alert(__("Target task can't start before source task starts."));
575+
gantt.alert(__("Target task can't start before source task starts.", 'gantt'));
574576
valid = false;
575577
} else if (type == gantt.config.links.finish_to_finish && target.end_date < source.end_date) {
576-
gantt.alert(__("Target task can't end before source task ends."));
578+
gantt.alert(__("Target task can't end before source task ends.", 'gantt'));
577579
valid = false;
578580
} else if (type == gantt.config.links.start_to_finish && target.end_date < source.start_date) {
579-
gantt.alert(__("Target task can't end before the source task starts."));
581+
gantt.alert(__("Target task can't end before the source task starts.", 'gantt'));
580582
valid = false;
581583
}
582584
return valid;
@@ -604,7 +606,7 @@ var GlpiGantt = (function() {
604606
gantt.deleteTask(id);
605607
displayAjaxMessageAfterRedirect();
606608
} else {
607-
gantt.alert(__('Could not create task: ') + json.error);
609+
gantt.alert(__('Could not create task: ', 'gantt') + json.error);
608610
}
609611
},
610612
error: function(resp) {
@@ -638,7 +640,7 @@ var GlpiGantt = (function() {
638640
gantt.hideLightbox();
639641
displayAjaxMessageAfterRedirect();
640642
} else
641-
gantt.alert(__('Could not update Task[%s]: ').replace('%s', item.text) + json.error);
643+
gantt.alert(__('Could not update Task[%s]: ', 'gantt').replace('%s', item.text) + json.error);
642644
},
643645
error: function(resp) {
644646
gantt.alert(resp.responseText);
@@ -665,7 +667,7 @@ var GlpiGantt = (function() {
665667
gantt.updateTask(task.id);
666668
displayAjaxMessageAfterRedirect();
667669
} else {
668-
gantt.alert(__('Could not update Task[%s]: ').replace('%s', task.text) + json.error);
670+
gantt.alert(__('Could not update Task[%s]: ', 'gantt').replace('%s', task.text) + json.error);
669671
gantt.undo();
670672
}
671673
}
@@ -743,7 +745,7 @@ var GlpiGantt = (function() {
743745
gantt.deleteTask(id);
744746
displayAjaxMessageAfterRedirect();
745747
} else {
746-
gantt.alert(__('Could not create project: ') + json.error);
748+
gantt.alert(__('Could not create project: ', 'gantt') + json.error);
747749
}
748750
},
749751
error: function(resp) {
@@ -771,7 +773,7 @@ var GlpiGantt = (function() {
771773
gantt.hideLightbox();
772774
displayAjaxMessageAfterRedirect();
773775
} else {
774-
gantt.alert(__('Could not update Project[%s]: ').replace('%s', item.text) + json.error);
776+
gantt.alert(__('Could not update Project[%s]: ', 'gantt').replace('%s', item.text) + json.error);
775777
}
776778
},
777779
error: function(resp) {

locales/ar_SA.mo

731 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)