Skip to content

Commit 50fa2c0

Browse files
committed
We need a common global language file
1 parent e0e6e32 commit 50fa2c0

6 files changed

Lines changed: 123 additions & 8 deletions

File tree

event/listener.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,33 @@ public function __construct(config $config, controller_helper $controller_helper
8282
public static function getSubscribedEvents()
8383
{
8484
return [
85-
'core.page_header_after' => [['load_template_data'], ['pwa_manifest']],
86-
'core.ucp_display_module_before' => 'load_language',
87-
'core.acp_main_notice' => 'compatibility_notice',
85+
'core.user_setup' => 'load_language_on_setup',
86+
'core.page_header_after' => [['load_template_data'], ['pwa_manifest']],
87+
'core.ucp_display_module_before' => 'load_language',
88+
'core.acp_main_notice' => 'compatibility_notice',
8889
'core.acp_board_config_edit_add' => 'acp_pwa_options',
89-
'core.acp_board_config_emoji_enabled'=> 'acp_pwa_allow_emoji',
90-
'core.validate_config_variable' => 'validate_pwa_options',
91-
'core.help_manager_add_block_after' => 'wpn_faq',
90+
'core.acp_board_config_emoji_enabled' => 'acp_pwa_allow_emoji',
91+
'core.validate_config_variable' => 'validate_pwa_options',
92+
'core.help_manager_add_block_after' => 'wpn_faq',
9293
];
9394
}
9495

96+
/**
97+
* Load common language file during user setup
98+
*
99+
* @param \phpbb\event\data $event The event object
100+
* @return void
101+
*/
102+
public function load_language_on_setup($event)
103+
{
104+
$lang_set_ext = $event['lang_set_ext'];
105+
$lang_set_ext[] = array(
106+
'ext_name' => 'phpbb/webpushnotifications',
107+
'lang_set' => 'common',
108+
);
109+
$event['lang_set_ext'] = $lang_set_ext;
110+
}
111+
95112
/**
96113
* Load template data
97114
*/

language/en/common.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2026, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = [];
22+
}
23+
24+
// DEVELOPERS PLEASE NOTE
25+
//
26+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
27+
//
28+
// Placeholders can now contain order information, e.g. instead of
29+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
30+
// translators to re-order the output of data while ensuring it remains correct
31+
//
32+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
33+
// equally where a string contains only two placeholders which are used to wrap text
34+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
35+
//
36+
// Some characters you may want to copy&paste:
37+
// ’ » “ ” …
38+
//
39+
40+
$lang = array_merge($lang, [
41+
'WEBPUSH_INVALID_ENDPOINT' => 'The push notification endpoint is not from a recognised push service.',
42+
]);

language/en/webpushnotifications_module_ucp.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@
5757
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'We show a reminder asking you to allow browser notifications when they are not currently enabled or when we cannot detect them. Turn this off to permanently stop these reminder pop-ups on all your devices. If you turn this off, you will not be warned if your browser notifications stop working in the future.',
5858
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Enable reminders',
5959
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Disable reminders',
60-
'WEBPUSH_INVALID_ENDPOINT' => 'The push notification endpoint is not from a recognised push service.',
6160
]);

language/ru/common.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2026, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = [];
22+
}
23+
24+
// DEVELOPERS PLEASE NOTE
25+
//
26+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
27+
//
28+
// Placeholders can now contain order information, e.g. instead of
29+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
30+
// translators to re-order the output of data while ensuring it remains correct
31+
//
32+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
33+
// equally where a string contains only two placeholders which are used to wrap text
34+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
35+
//
36+
// Some characters you may want to copy&paste:
37+
// ’ » “ ” …
38+
//
39+
40+
$lang = array_merge($lang, [
41+
'WEBPUSH_INVALID_ENDPOINT' => 'Конечная точка push-уведомления не принадлежит известному сервису push-уведомлений.',
42+
]);

language/ru/webpushnotifications_module_ucp.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@
5757
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Мы показываем напоминание с просьбой разрешить уведомления браузера, если они сейчас не включены или если мы не можем их обнаружить. Отключите эту функцию, чтобы навсегда убрать эти напоминания на всех ваших устройствах. Если вы отключите эту функцию, вы больше не будете получать предупреждения, если уведомления браузера перестанут работать в будущем.',
5858
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Включить напоминания',
5959
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Отключить напоминания',
60-
'WEBPUSH_INVALID_ENDPOINT' => 'Конечная точка push-уведомления не принадлежит известному сервису push-уведомлений.',
6160
]);

tests/event/listener_test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function test_construct()
141141
public function test_getSubscribedEvents()
142142
{
143143
self::assertEquals([
144+
'core.user_setup',
144145
'core.page_header_after',
145146
'core.ucp_display_module_before',
146147
'core.acp_main_notice',
@@ -151,6 +152,21 @@ public function test_getSubscribedEvents()
151152
], array_keys(\phpbb\webpushnotifications\event\listener::getSubscribedEvents()));
152153
}
153154

155+
public function test_load_language_on_setup()
156+
{
157+
$this->set_listener();
158+
159+
$data = new \phpbb\event\data(array('lang_set_ext'));
160+
$this->listener->load_language_on_setup($data);
161+
162+
self::assertEquals(array(
163+
array(
164+
'ext_name' => 'phpbb/webpushnotifications',
165+
'lang_set' => 'common',
166+
),
167+
), $data['lang_set_ext']);
168+
}
169+
154170
public function test_load_language()
155171
{
156172
$this->set_listener();

0 commit comments

Comments
 (0)