Skip to content

Commit

Permalink
feat-400: fix local ts file execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Füting committed Dec 6, 2024
1 parent f938eb1 commit 2881ed7
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 23 deletions.
12 changes: 6 additions & 6 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@
"test:unit:nowatch": "vitest run src",
"test:unit:coverage": "vitest src --coverage",
"test:e2e": "playwright test",
"run:node": "cross-env NODE_ENV=development BABEL_ENV=development babel-node --config-file \"./babel-node.config.js\" --extensions '.ts'",
"run:node:prod": "cross-env NODE_ENV=production BABEL_ENV=production babel-node --config-file \"./babel-node.config.js\" --extensions '.ts'",
"stills": "yarn run:node tools/generateStillImages.ts",
"i18n:extract": "yarn i18next -c config/i18next/i18next.config.js",
"i18n:addkeys": "babel-node --config-file \"./babel-node.config.js\" --extensions \".ts\" tools/addLocaleKeys.ts",
"i18n:fix": "babel-node --config-file \"./babel-node.config.js\" --extensions \".ts\" tools/fixLocales.ts",
"stills": "tsx tools/generateStillImages.ts",
"i18n:extract": "i18next -c config/i18next/i18next.config.js",
"i18n:addkeys": "tsx tools/addLocaleKeys.ts",
"i18n:fix": "tsx tools/fixLocales.ts",
"i18n:translate": "json-autotranslate --config=json-autotranslate.json --input=src/i18n/resources --service=amazon-translate --matcher=i18next --fix-inconsistencies --delete-unused-strings"
},
"dependencies": {
Expand Down Expand Up @@ -272,10 +270,12 @@
"set.prototype.tojson": "^0.1.1",
"source-map-loader": "^5.0.0",
"style-loader": "^4.0.0",
"stylelint": "^16.11.0",
"svgo": "^3.3.2",
"ts-essentials": "^10.0.3",
"ts-node": "^10.9.2",
"ts-toolbelt": "^9.6.0",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript-eslint": "8.17.0",
"url-loader": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion web/src/helpers/safeZip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { zip } from 'lodash'
import zip from 'lodash/zip'

export function safeZip<T, U>(first: T[], second: U[]) {
const firstLen = first.length
Expand Down
6 changes: 3 additions & 3 deletions web/src/i18n/resources/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
"Country": "国家",
"Frequency": "频率",
"{{asterisk}} Interpolated values": "{{asterisk}} 内插值",
"Dedicated {{nextstrain}} build for {{variant}}": "{{variant}}{{nextstrain}} 构建",
"Dedicated {{nextstrain}} build for {{variant}}": "{{variant}}{{nextstrain}} 构建",
"Reversed": "倒排",
"Defining mutations": "定义突变",
"None. See notes below": "没有。参见下面的注释",
"Nonsynonymous": "非同义词",
"Synonymous": "同义词",
"Compare": "比较",
"Distribution of {{variant}} per country": "{{variant}} 每个国家的分布",
"Protein visualisation for {{variant}} by {{aquaria}}": " {{variant}} 蛋白质可视化,由 {{aquaria}}提供",
"Protein visualisation for {{variant}} by {{aquaria}}": " {{variant}} 蛋白质可视化,由 {{aquaria}} 提供",
"Count": "计数",
"Data is from {{source}}": "数据来自 {{source}}",
"Gene S": "刺突基因",
Expand All @@ -85,7 +85,7 @@
"Phylogenetic relationships of SARS-CoV-2 clades as defined by {{nextstrain}}": "SARS-CoV-2 进化论的系统发育关系定义为 {{nextstrain}}",
"source": "资源",
"No dedicated {{nextstrain}} build is available": "没有专用 {{nextstrain}} 版本可用",
"{{nextstrain}} Clade": "{{nextstrain}}进化枝",
"{{nextstrain}} Clade": "{{nextstrain}} 进化枝",
"Mutations": "突变",
"Show less": "显示更少",
"Show more": "显示更多",
Expand Down
3 changes: 2 additions & 1 deletion web/tools/addLocaleKeys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import fs from 'fs-extra'
import { sortBy, uniqBy } from 'lodash'
import sortBy from 'lodash/sortBy'
import uniqBy from 'lodash/uniqBy'
import { I18N_RESOURCES_DIR, I18N_RESOURCES_DEFAULT_LOCALE_FILE, readJson } from './fixLocales'

const ADDITIONAL_KEYS_FILE = path.join(I18N_RESOURCES_DIR, '../additional_keys.json')
Expand Down
10 changes: 8 additions & 2 deletions web/tools/fixLocales.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import path from 'path'
import * as url from 'node:url'
import fs from 'fs-extra'
import { difference, isObject, padStart, isEmpty, get } from 'lodash'
import difference from 'lodash/difference'
import isObject from 'lodash/isObject'
import padStart from 'lodash/padStart'
import isEmpty from 'lodash/isEmpty'
import get from 'lodash/get'
import { notUndefined } from 'src/helpers/notUndefined'
import { safeZip } from 'src/helpers/safeZip'

Expand Down Expand Up @@ -162,6 +167,7 @@ function main() {
})
}

if (require.main === module) {
const modulePath = url.fileURLToPath(import.meta.url)
if (process.argv[1] === modulePath) {
main()
}
Loading

0 comments on commit 2881ed7

Please sign in to comment.