extractText from translations where strings expected

This commit is contained in:
Alexander Skvortsov 2021-12-12 15:43:19 -05:00
parent cc69211977
commit 1bdfe0112c
No known key found for this signature in database
GPG Key ID: C4E3BBF9C3412B4C
3 changed files with 10 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import RequestError from '../../common/utils/RequestError';
import { Extension } from '../AdminApplication';
import { IPageAttrs } from '../../common/components/Page';
import type Mithril from 'mithril';
import extractText from '../../common/utils/extractText';
export interface ExtensionPageAttrs extends IPageAttrs {
id: string;
@ -156,7 +157,7 @@ export default class ExtensionPage<Attrs extends ExtensionPageAttrs = ExtensionP
if (!this.isEnabled()) {
const purge = () => {
if (confirm(app.translator.trans('core.admin.extension.confirm_purge'))) {
if (confirm(extractText(app.translator.trans('core.admin.extension.confirm_purge')))) {
app
.request({
url: app.forum.attribute('apiUrl') + '/extensions/' + this.extension.id,

View File

@ -1,4 +1,5 @@
import app from '../../common/app';
import extractText from './extractText';
/**
* The `abbreviateNumber` utility converts a number to a shorter localized form.
@ -10,9 +11,9 @@ import app from '../../common/app';
export default function abbreviateNumber(number: number): string {
// TODO: translation
if (number >= 1000000) {
return Math.floor(number / 1000000) + app.translator.trans('core.lib.number_suffix.mega_text');
return Math.floor(number / 1000000) + extractText(app.translator.trans('core.lib.number_suffix.mega_text'));
} else if (number >= 1000) {
return (number / 1000).toFixed(1) + app.translator.trans('core.lib.number_suffix.kilo_text');
return (number / 1000).toFixed(1) + extractText(app.translator.trans('core.lib.number_suffix.kilo_text'));
} else {
return number.toString();
}

View File

@ -23,6 +23,7 @@ import isSafariMobile from './utils/isSafariMobile';
import type Notification from './components/Notification';
import type Post from './components/Post';
import Discussion from '../common/models/Discussion';
import extractText from '../common/utils/extractText';
export default class ForumApplication extends Application {
/**
@ -99,7 +100,7 @@ export default class ForumApplication extends Application {
}
this.routes[defaultAction].path = '/';
this.history.push(defaultAction, this.translator.trans('core.forum.header.back_to_index_tooltip'), '/');
this.history.push(defaultAction, extractText(this.translator.trans('core.forum.header.back_to_index_tooltip')), '/');
this.pane = new Pane(document.getElementById('app'));
@ -124,8 +125,9 @@ export default class ForumApplication extends Application {
app.history.home();
// Reload the current user so that their unread notification count is refreshed.
if (app.session.user) {
app.store.find('users', app.session.user.id());
const userId = app.session.user?.id()
if (userId) {
app.store.find('users', userId);
m.redraw();
}
});