Skip to content

Commit 54bd220

Browse files
committed
refactor: stats column getName, remove localeKey
1 parent 202661f commit 54bd220

File tree

4 files changed

+6
-28
lines changed

4 files changed

+6
-28
lines changed

app/scripts/components/statistics/statistics.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,6 @@ angular.module("korpApp").component("statistics", {
254254
createExamplesTask,
255255
)
256256

257-
const refreshHeaders = () =>
258-
$(".localized-header .slick-column-name")
259-
.not("[rel^=localize]")
260-
.each(function () {
261-
;($(this) as JQueryExtended).localeKey($(this).text())
262-
})
263-
264-
grid.onHeaderCellRendered.subscribe((e, args) => refreshHeaders())
265-
266-
refreshHeaders()
267257
$(window).trigger("resize")
268258

269259
updateGraphBtnState()

app/scripts/jq_extensions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
import { loc } from "@/i18n"
2-
3-
$.fn.localeKey = function (key) {
4-
this.each(function () {
5-
$(this).attr("rel", `localize[${key}]`).html(loc(key))
6-
})
7-
return this
8-
}
9-
101
/*
112
* A file generation plugin modified from that by Martin Angelov:
123
* http://tutorialzine.com/2011/05/generating-files-javascript-php/

app/scripts/jquery.types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export type JQueryExtended<T = HTMLElement> = JQuery<T> & {
22
// Defined in /app/lib/jquery.localize.js, a modified version of jquery-localize
33
localize: () => JQueryExtended<T>
4-
// Defined in jq_extensions
5-
localeKey: (key: string) => JQueryExtended<T>
64
}
75

86
export type JQueryStaticExtended = JQueryStatic & {

app/scripts/statistics/statistics-grid.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import "slickgrid/slick.grid.css"
77
import { Dataset, isTotalRow, Row, SingleRow } from "./statistics.types"
88
import { StoreService } from "@/services/store"
99
import settings from "@/settings"
10-
import { locObj } from "@/i18n"
10+
import { loc, locObj } from "@/i18n"
1111
import { formatFrequency } from "@/i18n/util"
12-
import { LangString } from "@/i18n/types"
1312
import { zip } from "lodash"
1413
import { corpusListing } from "@/corpora/corpus_listing"
1514

@@ -74,7 +73,7 @@ export class StatisticsGrid extends Slick.Grid<Row> {
7473
refreshColumns() {
7574
const columns = this.getColumns() as SlickgridColumn[]
7675
columns.forEach((column) => {
77-
if (column.translation) column.name = locObj(column.translation, this.store.lang)
76+
if (column.getName) column.name = column.getName(this.store.lang)
7877
})
7978
this.setColumns(columns)
8079
}
@@ -109,7 +108,7 @@ function createColumns(store: StoreService, corpora: string[], attrs: string[]):
109108
if (reduceVal == null || reduceValLabel == null) break
110109
columns.push({
111110
id: reduceVal,
112-
translation: reduceValLabel,
111+
getName: (lang) => locObj(reduceValLabel!, lang),
113112
field: "hit_value",
114113
sortable: true,
115114
formatter: (row, cell, value, columnDef, data: Row) => {
@@ -135,7 +134,7 @@ function createColumns(store: StoreService, corpora: string[], attrs: string[]):
135134

136135
columns.push({
137136
id: "total",
138-
name: "stats_total",
137+
getName: (lang) => loc("stats_total", lang),
139138
field: "total",
140139
sortable: true,
141140
defaultSortAsc: false,
@@ -151,7 +150,7 @@ function createColumns(store: StoreService, corpora: string[], attrs: string[]):
151150
corpora.forEach((id) =>
152151
columns.push({
153152
id,
154-
translation: settings.corpora[id.toLowerCase()].title,
153+
getName: (lang) => locObj(settings.corpora[id.toLowerCase()].title, lang),
155154
field: "count",
156155
sortable: true,
157156
defaultSortAsc: false,
@@ -168,5 +167,5 @@ function createColumns(store: StoreService, corpora: string[], attrs: string[]):
168167
}
169168

170169
type SlickgridColumn = Slick.Column<Dataset> & {
171-
translation?: LangString
170+
getName?: (lang: string) => string
172171
}

0 commit comments

Comments
 (0)