Skip to content

Commit 0f44de7

Browse files
committed
init i18n
1 parent 814a9d1 commit 0f44de7

File tree

8 files changed

+33
-5
lines changed

8 files changed

+33
-5
lines changed

bun.lock

100755100644
Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
55
"main": "index.js",
66
"bin": {
7-
"pushy": "lib/index.js"
7+
"pushy": "lib/index.js",
8+
"cresc": "lib/index.js"
89
},
910
"files": [
1011
"lib",
@@ -46,6 +47,7 @@
4647
"form-data": "^4.0.1",
4748
"fs-extra": "8",
4849
"gradle-to-js": "^2.0.1",
50+
"i18next": "^24.2.2",
4951
"isomorphic-unzip": "^1.1.5",
5052
"node-fetch": "^2.6.1",
5153
"plist": "^3.1.0",

src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export async function uploadFile(fn: string, key?: string) {
121121
timeout: 1000,
122122
});
123123
// console.log({pingResult});
124-
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
124+
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
125125
realUrl = backupUrl;
126126
}
127127
}

src/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
import { loadSession } from './api';
44
import updateNotifier from 'update-notifier';
5-
import { printVersionCommand } from './utils/index.js';
5+
import { printVersionCommand } from './utils';
66
import pkg from '../package.json';
7+
import path from 'node:path';
8+
import i18next from 'i18next';
9+
10+
const scriptName: 'cresc' | 'pushy' = path.basename(process.argv[1]) as
11+
| 'cresc'
12+
| 'pushy';
13+
global.IS_CRESC = scriptName === 'cresc';
14+
15+
i18next.init({
16+
lng: global.IS_CRESC ? 'en' : 'zh',
17+
debug: process.env.NODE_ENV !== 'production',
18+
resources: {
19+
en: require('./locales/en.json'),
20+
zh: require('./locales/zh.json'),
21+
},
22+
});
723

824
updateNotifier({ pkg }).notify({
925
isGlobal: true,

src/locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/locale/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare global {
22
var NO_INTERACTIVE: boolean;
33
var USE_ACC_OSS: boolean;
4+
var IS_CRESC: boolean;
45
}
56

67
export interface Session {

src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function getRNVersion() {
5555
};
5656
}
5757

58-
export async function getApkInfo(fn) {
58+
export async function getApkInfo(fn: string) {
5959
const appInfoParser = new AppInfoParser(fn);
6060
const bundleFile = await appInfoParser.parser.getEntry(
6161
/assets\/index.android.bundle/,

0 commit comments

Comments
 (0)