Skip to content

Commit 52f42ae

Browse files
daniil-bergseruppMarion Hilgers
committed
feat!: standardize language strings (close #29)
Almost all string IDs use namespacing/scoping via colons. Currently the prefixes `error:`, `event:`, `metric:`, and `settings:` exist. The remaining ones are forced to follow a certain pattern by Moodle. Word separation via underscores is used consistently (wherever possible). Metric descriptions match metric names exactly and have a `metric:` prefix and `_description` suffix. Metric config options also have the `metric:` prefix, followed by the config class name and another colon, followed by the actual option name. Co-authored-by: Sebastian Rupp <sr@artcodix.com> Co-authored-by: Marion Hilgers <mh@artcodix.com>
1 parent cf0d312 commit 52f42ae

22 files changed

Lines changed: 82 additions & 75 deletions

classes/event/metric_config_updated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class metric_config_updated extends metric_event {
5151
*/
5252
#[\Override]
5353
public static function get_name(): lang_string {
54-
return new lang_string('metricconfigupdated', 'tool_monitoring');
54+
return new lang_string('event:metric_config_updated', 'tool_monitoring');
5555
}
5656

5757
/**

classes/form/config.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ protected function definition(): void {
6363
$this->_form->setType('metric', PARAM_ALPHAEXT);
6464
$this->add_static_field(
6565
name: 'component',
66-
label: new lang_string('component', 'tool_monitoring'),
66+
label: new lang_string('settings:component', 'tool_monitoring'),
6767
value: $this->metric->component,
6868
);
6969
$this->add_static_field(
7070
name: 'name',
71-
label: new lang_string('name', 'tool_monitoring'),
71+
label: new lang_string('settings:name', 'tool_monitoring'),
7272
value: $this->metric->name,
7373
);
7474
$this->add_static_field(
7575
name: 'type',
76-
label: new lang_string('type', 'tool_monitoring'),
76+
label: new lang_string('settings:type', 'tool_monitoring'),
7777
value: $this->metric->type->value,
7878
);
7979
$this->add_static_field(
8080
name: 'description',
81-
label: new lang_string('description', 'tool_monitoring'),
81+
label: new lang_string('settings:description', 'tool_monitoring'),
8282
value: $this->metric->description,
8383
);
8484
$this->add_advanced_checkbox_field(
8585
name: 'enabled',
86-
label: new lang_string('metricenabled', 'tool_monitoring'),
86+
label: new lang_string('settings:metric_enabled', 'tool_monitoring'),
8787
);
8888
$this->add_tags_field(
8989
itemtype: 'metrics',

classes/local/metrics/courses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function get_type(): metric_type {
5959
* {@inheritDoc}
6060
*/
6161
public static function get_description(): lang_string {
62-
return new lang_string('courses_description', 'tool_monitoring');
62+
return new lang_string('metric:courses_description', 'tool_monitoring');
6363
}
6464

6565
/**

classes/local/metrics/overdue_tasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class overdue_tasks extends metric {
5656
* {@inheritDoc}
5757
*/
5858
public static function get_description(): lang_string {
59-
return new lang_string('overdue_tasks_description', 'tool_monitoring');
59+
return new lang_string('metric:overdue_tasks_description', 'tool_monitoring');
6060
}
6161

6262
/**

classes/local/metrics/quiz_attempts_in_progress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static function get_type(): metric_type {
6363
* {@inheritDoc}
6464
*/
6565
public static function get_description(): lang_string {
66-
return new lang_string('quiz_attempts_in_progress_description', 'tool_monitoring');
66+
return new lang_string('metric:quiz_attempts_in_progress_description', 'tool_monitoring');
6767
}
6868

6969
/**

classes/local/metrics/user_accounts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function get_type(): metric_type {
6060
* {@inheritDoc}
6161
*/
6262
public static function get_description(): lang_string {
63-
return new lang_string('user_accounts_description', 'tool_monitoring');
63+
return new lang_string('metric:user_accounts_description', 'tool_monitoring');
6464
}
6565

6666
/**

classes/local/metrics/users_online.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function get_type(): metric_type {
6060
* {@inheritDoc}
6161
*/
6262
public static function get_description(): lang_string {
63-
return new lang_string('users_online_description', 'tool_monitoring');
63+
return new lang_string('metric:users_online_description', 'tool_monitoring');
6464
}
6565

6666
/**

classes/local/metrics/users_online_config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ public function to_form_data(): array {
137137

138138
#[\Override]
139139
public static function extend_form_definition(config_form $configform, MoodleQuickForm $mform): void {
140-
$mform->addElement('text', 'timewindows', new lang_string('users_online_time_windows', 'tool_monitoring'));
140+
$mform->addElement('text', 'timewindows', new lang_string('metric:users_online_config:timewindows', 'tool_monitoring'));
141141
$mform->setType('timewindows', PARAM_TEXT);
142-
$mform->addHelpButton('timewindows', 'users_online_time_windows', 'tool_monitoring');
142+
$mform->addHelpButton('timewindows', 'metric:users_online_config:timewindows', 'tool_monitoring');
143143
$mform->addRule('timewindows', null, 'required', null, 'client');
144144
}
145145

configure.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
$qualifiedname = required_param('metric', PARAM_ALPHAEXT);
4646
$PAGE->set_url('/admin/tool/monitoring/configure.php', ['metric' => $qualifiedname]);
4747
$PAGE->set_context($context);
48-
$PAGE->set_title(get_string('monitoring_metrics', 'tool_monitoring'));
49-
$PAGE->set_heading(get_string('monitoring_metrics', 'tool_monitoring'));
48+
$PAGE->set_title(get_string('settings:monitoring_metrics', 'tool_monitoring'));
49+
$PAGE->set_heading(get_string('settings:monitoring_metrics', 'tool_monitoring'));
5050
$PAGE->add_body_class('limitedwidth');
5151

5252
$manager = new metrics_manager();

exporter/prometheus/lang/en/monitoringexporter_prometheus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
*/
2929

3030
$string['pluginname'] = 'Exporter Prometheus';
31-
$string['setting_token'] = 'Token';
32-
$string['setting_token_desc'] = 'The token which has to be passed when the endpoint is called.';
31+
$string['settings:token'] = 'Token';
32+
$string['settings:token_desc'] = 'The token which has to be passed when the endpoint is called.';

0 commit comments

Comments
 (0)