Skip to content

Commit

Permalink
fix: caught warnings and missing locale
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Oct 25, 2024
1 parent 30c7602 commit 4715293
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
16 changes: 6 additions & 10 deletions extensions/package-manager/js/src/admin/extend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ export default [
.setting(() => ({
setting: 'flarum-extension-manager.queue_jobs',
label: app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs'),
help: m.trust(
extractText(
app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs_help', {
basic_impl_link: 'https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting',
adv_impl_link: 'https://discuss.flarum.org/d/21873-redis-sessions-cache-queues',
php_version: `<strong>${app.data.phpVersion}</strong>`,
folder_perms_link: 'https://docs.flarum.org/install#folder-ownership',
})
)
),
help: app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs_help', {
basic_impl_link: <a href="https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting" />,
adv_impl_link: <a href="https://discuss.flarum.org/d/21873-redis-sessions-cache-queues" />,
php_version: <strong>{app.data.phpVersion}</strong>,
folder_perms_link: <a href="https://docs.flarum.org/install#folder-ownership" />,
}),
type: 'boolean',
disabled: app.data['flarum-extension-manager.using_sync_queue'],
}))
Expand Down
5 changes: 3 additions & 2 deletions extensions/package-manager/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ flarum-extension-manager:
party_filter:
all: All
premium: Premium
toggle_dropdown_accessible_label: Toggle party filter
queue:
columns:
details: Details
Expand Down Expand Up @@ -169,8 +170,8 @@ flarum-extension-manager:
debug_mode_warning: You are running in debug mode, the extension manager cannot properly install and update local development packages. Please use the command line interface instead for such purposes.
queue_jobs: Run operations in the background queue
queue_jobs_help: >
You can read about a <a href='{basic_impl_link}'>basic queue</a> implementation or a <a href='{adv_impl_link}'>more advanced</a> one.
Make sure the PHP version used for the queue is {php_version}. Make sure <a href='{folder_perms_link}'>folder permissions</a> are correctly configured.
You can read about a <basic_impl_link>basic queue</basic_impl_link> implementation or a <adv_impl_link>more advanced</adv_impl_link> one.
Make sure the PHP version used for the queue is {php_version}. Make sure <folder_perms_link>folder permissions</folder_perms_link> are correctly configured.
task_retention_days: Task retention days
task_retention_days_help: >
The number of days to keep completed tasks in the database. Tasks older than this will be deleted.
Expand Down
15 changes: 7 additions & 8 deletions framework/core/js/src/common/Translator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,10 @@ export default class Translator {
const elements = translation.match(/<(\w+)[^>]*>.*?<\/\1>/g);
const tags = elements?.map((element) => element.match(/^<(\w+)/)![1]) || [];

for (const tag of tags) {
if (!parameters[tag]) {
fireDebugWarning(
`Any HTML tags used within translations must have corresponding mithril component parameters.\nCaught in translation: \n\n"""\n${translation}\n"""`,
'',
'v2.0',
'flarum/framework'
);
const autoProvidedTags = this.autoProvidedTags();

for (const tag of tags) {
if (!parameters[tag] && autoProvidedTags.includes(tag)) {
parameters[tag] = ({ children }: any) => m(tag, children);
}
}
Expand Down Expand Up @@ -186,4 +181,8 @@ export default class Translator {

return translation;
}

autoProvidedTags(): string[] {
return ['strong', 'code', 'i', 's', 'em', 'sup', 'sub'];
}
}
12 changes: 6 additions & 6 deletions framework/core/js/src/common/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ export default class Pagination<CustomAttrs extends IPaginationInterface = IPagi
<nav className="Pagination">
<Button
disabled={currentPage === 1}
title={app.translator.trans('core.admin.users.pagination.first_page_button')}
title={app.translator.trans('core.lib.pagination.first_button')}
onclick={() => onChange(1)}
icon="fas fa-step-backward"
className="Button Button--icon Pagination-first"
/>
<Button
disabled={currentPage === 1}
title={app.translator.trans('core.admin.users.pagination.back_button')}
title={app.translator.trans('core.lib.pagination.back_button')}
onclick={() => onChange(currentPage - 1)}
icon="fas fa-chevron-left"
className="Button Button--icon Pagination-back"
/>
<span className="Pagination-pageNumber">
{app.translator.trans('core.admin.users.pagination.page_counter', {
{app.translator.trans('core.lib.pagination.page_counter', {
// https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/
current: (
<input
type="text"
inputmode="numeric"
pattern="[0-9]*"
value={loadingPageNumber ?? currentPage}
aria-label={extractText(app.translator.trans('core.admin.users.pagination.go_to_page_textbox_a11y_label'))}
aria-label={extractText(app.translator.trans('core.lib.pagination.go_to_page_textbox_a11y_label'))}
autocomplete="off"
className="FormControl Pagination-input"
onchange={(e: InputEvent) => {
Expand Down Expand Up @@ -76,14 +76,14 @@ export default class Pagination<CustomAttrs extends IPaginationInterface = IPagi
</span>
<Button
disabled={!moreData}
title={app.translator.trans('core.admin.users.pagination.next_button')}
title={app.translator.trans('core.lib.pagination.next_button')}
onclick={() => onChange(currentPage + 1)}
icon="fas fa-chevron-right"
className="Button Button--icon Pagination-next"
/>
<Button
disabled={!moreData}
title={app.translator.trans('core.admin.users.pagination.last_page_button')}
title={app.translator.trans('core.lib.pagination.last_button')}
onclick={() => onChange(totalPageCount)}
icon="fas fa-step-forward"
className="Button Button--icon Pagination-last"
Expand Down
17 changes: 9 additions & 8 deletions framework/core/locale/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,6 @@ core:

invalid_column_content: Invalid

pagination:
back_button: Previous page
first_button: Go to first page
go_to_page_textbox_a11y_label: Go directly to page number
last_button: Go to last page
next_button: Next page
page_counter: Page {current} of {total}

search_placeholder: => core.ref.search_users
title: => core.ref.users
total_users: "Total users: {count}"
Expand Down Expand Up @@ -802,6 +794,15 @@ core:
kilo_text: K
mega_text: M

# These translations are used in the common pagination component.
pagination:
back_button: Previous page
first_button: Go to first page
go_to_page_textbox_a11y_label: Go directly to page number
last_button: Go to last page
next_button: Next page
page_counter: Page {current} of {total}

# These translations are used by the abstract search component and search modal.
search:
gambit_plus_button_a11y_label: Add a positive filter
Expand Down

0 comments on commit 4715293

Please sign in to comment.