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
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"lockfileVersion": 0,
2+
"lockfileVersion": 1,
33
"workspaces": {
44
"": {
55
"dependencies": {
@@ -15,6 +15,7 @@
1515
"form-data": "^4.0.1",
1616
"fs-extra": "8",
1717
"gradle-to-js": "^2.0.1",
18+
"i18next": "^24.2.2",
1819
"isomorphic-unzip": "^1.1.5",
1920
"node-fetch": "^2.6.1",
2021
"plist": "^3.1.0",
@@ -38,6 +39,8 @@
3839
},
3940
},
4041
"packages": {
42+
"@babel/runtime": ["@babel/[email protected]", "", { "dependencies": { "regenerator-runtime": "^0.14.0" } }, "sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg=="],
43+
4144
"@badisi/latest-version": ["@badisi/[email protected]", "", { "dependencies": { "@colors/colors": "^1.6.0", "global-dirs": "3.0.1", "ora": "^8.1.0", "registry-auth-token": "^5.0.2", "semver": "^7.6.3" }, "bin": { "latest-version": "bin/latest-version", "lv": "bin/latest-version" } }, "sha512-1lX9wvXiJC552C+rrwwjEbpvvuDwYTU3OLFwFA1pTVYTnJGUkbBkfqz1MuTIPP1fL2LCvjd21ri/u39sSIcMTg=="],
4245

4346
"@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "1.9.4", "@biomejs/cli-darwin-x64": "1.9.4", "@biomejs/cli-linux-arm64": "1.9.4", "@biomejs/cli-linux-arm64-musl": "1.9.4", "@biomejs/cli-linux-x64": "1.9.4", "@biomejs/cli-linux-x64-musl": "1.9.4", "@biomejs/cli-win32-arm64": "1.9.4", "@biomejs/cli-win32-x64": "1.9.4" }, "bin": { "biome": "bin/biome" } }, "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog=="],
@@ -414,6 +417,8 @@
414417

415418
"human-signals": ["[email protected]", "", {}, "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="],
416419

420+
"i18next": ["[email protected]", "", { "dependencies": { "@babel/runtime": "^7.23.2" }, "peerDependencies": { "typescript": "^5" }, "optionalPeers": ["typescript"] }, "sha512-NE6i86lBCKRYZa5TaUDkU5S4HFgLIEJRLr3Whf2psgaxBleQ2LC1YW1Vc+SCgkAW7VEzndT6al6+CzegSUHcTQ=="],
421+
417422
"ieee754": ["[email protected]", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
418423

419424
"import-lazy": ["[email protected]", "", {}, "sha512-m7ZEHgtw69qOGw+jwxXkHlrlIPdTGkyh66zXZ1ajZbxkDBNjSY/LGbmjc7h0s2ELsUDTAhFr55TrPSSqJGPG0A=="],
@@ -604,6 +609,8 @@
604609

605610
"read": ["[email protected]", "", { "dependencies": { "mute-stream": "^2.0.0" } }, "sha512-nbYGT3cec3J5NPUeJia7l72I3oIzMIB6yeNyDqi8CVHr3WftwjrCUqR0j13daoHEMVaZ/rxCpmHKrbods3hI2g=="],
606611

612+
"regenerator-runtime": ["[email protected]", "", {}, "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="],
613+
607614
"regexp.prototype.flags": ["[email protected]", "", { "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", "es-errors": "^1.3.0", "set-function-name": "^2.0.2" } }, "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ=="],
608615

609616
"registry-auth-token": ["[email protected]", "", { "dependencies": { "@pnpm/npm-conf": "^2.1.0" } }, "sha512-o/3ikDxtXaA59BmZuZrJZDJv8NMDGSj+6j6XaeBmHw8eY1i1qd9+6H+LjVvQXx3HN6aRCGa1cUdJ9RaJZUugnQ=="],

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)