Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support fa-IR #17

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
run_install: false

- name: Setup Node.js
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ jobs:
ref: ${{ github.ref_name }}

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
Expand Down
3 changes: 1 addition & 2 deletions examples/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { univerPlugin } from '@univerjs/esbuild-plugin'
import esbuild from 'esbuild'
import stylePlugin from 'esbuild-style-plugin'
import { univerPlugin } from '@univerjs/esbuild-plugin'

const ctx = await esbuild.context({
bundle: true,
Expand All @@ -20,5 +20,4 @@ await ctx.serve({
port: 3010,
})

// eslint-disable-next-line no-console
console.log(`Local server: http://localhost:3010`)
36 changes: 18 additions & 18 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@
"build": "tsc && vite build"
},
"dependencies": {
"@univerjs/core": "0.1.15",
"@univerjs/design": "0.1.15",
"@univerjs/docs": "0.1.15",
"@univerjs/docs-ui": "0.1.15",
"@univerjs/engine-formula": "0.1.15",
"@univerjs/engine-numfmt": "0.1.15",
"@univerjs/engine-render": "0.1.15",
"@univerjs/sheets": "0.1.15",
"@univerjs/sheets-formula": "0.1.15",
"@univerjs/sheets-numfmt": "0.1.15",
"@univerjs/sheets-ui": "0.1.15",
"@univerjs/sheets-zen-editor": "0.1.15",
"@univerjs/ui": "0.1.15"
"@univerjs/core": "0.4.0-alpha.1",
"@univerjs/design": "0.4.0-alpha.1",
"@univerjs/docs": "0.4.0-alpha.1",
"@univerjs/docs-ui": "0.4.0-alpha.1",
"@univerjs/engine-formula": "0.4.0-alpha.1",
"@univerjs/engine-numfmt": "0.4.0-alpha.1",
"@univerjs/engine-render": "0.4.0-alpha.1",
"@univerjs/sheets": "0.4.0-alpha.1",
"@univerjs/sheets-formula": "0.4.0-alpha.1",
"@univerjs/sheets-numfmt": "0.4.0-alpha.1",
"@univerjs/sheets-ui": "0.4.0-alpha.1",
"@univerjs/sheets-zen-editor": "0.4.0-alpha.1",
"@univerjs/ui": "0.4.0-alpha.1"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@univerjs/esbuild-plugin": "file:../packages/esbuild-plugin",
"@univerjs/vite-plugin": "file:../packages/vite-plugin",
"@univerjs/webpack-plugin": "file:../packages/webpack-plugin",
"css-loader": "^6.10.0",
"esbuild": "^0.21.5",
"esbuild": "^0.24.0",
"esbuild-style-plugin": "^1.6.3",
"html-webpack-plugin": "^5.6.0",
"style-loader": "^3.3.4",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"vite": "^5.3.1",
"webpack": "^5.92.0",
"webpack": "^5.95.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
"webpack-dev-server": "^5.1.0"
}
}
6 changes: 3 additions & 3 deletions examples/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './style.css'

import { LocaleType, LogLevel, Univer, UniverInstanceType } from '@univerjs/core'

import { defaultTheme } from '@univerjs/design'
import { UniverDocsPlugin } from '@univerjs/docs'
import { UniverDocsUIPlugin } from '@univerjs/docs-ui'
Expand All @@ -11,11 +10,12 @@ import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt'
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'
import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor'

import { UniverUIPlugin } from '@univerjs/ui'

import { enUS } from 'univer:locales'

import './style.css'

const univer = new Univer({
theme: defaultTheme,
locale: LocaleType.EN_US,
Expand Down
2 changes: 1 addition & 1 deletion examples/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import { univerPlugin } from '@univerjs/vite-plugin'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('node:path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { UniverPlugin } = require('@univerjs/webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// You'll need to find a webpack plugin equivalent for univerPlugin or adapt it if it's already compatible.
// const UniverWebpackPlugin = require('@univerjs/webpack-plugin');

Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"type": "module",
"version": "0.5.0",
"private": true,
"packageManager": "[email protected]",
"author": "DreamNum Inc. <[email protected]>",
"license": "Apache-2.0",
"engines": {
"node": ">=18.0.0"
"node": ">=18",
"pnpm": ">=9"
},
"scripts": {
"prepare": "simple-git-hooks",
Expand All @@ -17,12 +19,12 @@
"release": "release-it"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.1",
"@antfu/eslint-config": "^3.7.3",
"@release-it-plugins/workspaces": "^4.2.0",
"@release-it/conventional-changelog": "^8.0.1",
"eslint": "^9.5.0",
"lint-staged": "^15.2.7",
"release-it": "^17.3.0",
"@release-it/conventional-changelog": "^9.0.0",
"eslint": "^9.12.0",
"lint-staged": "^15.2.10",
"release-it": "^17.9.0",
"simple-git-hooks": "^2.11.1"
},
"simple-git-hooks": {
Expand Down
14 changes: 5 additions & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"test": "jest"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.14.5",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"mock-fs": "^5.2.0",
"ts-jest": "^29.1.5",
"typescript": "^5.4.5"
"mock-fs": "^5.4.0",
"ts-jest": "^29.2.5",
"typescript": "^5.6.3"
}
}
2 changes: 1 addition & 1 deletion packages/core/src/export-virtual-locales-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const virtualLocalesModuleId = 'univer:locales'
export function exportVirtualLocalesModule() {
const scopes = ['@univerjs', '@univerjs-pro']

const languages = ['en-US', 'ru-RU', 'zh-CN', 'vi-VN', 'zh-TW'].reduce((acc, lang) => {
const languages = ['en-US', 'ru-RU', 'zh-CN', 'vi-VN', 'zh-TW', 'fa-IR'].reduce((acc, lang) => {
acc[lang] = new Set()
return acc
}, {})
Expand Down
5 changes: 3 additions & 2 deletions packages/esbuild-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ npm install @univerjs/esbuild-plugin
If you are using the `esbuild` API, you can add the plugin to your build configuration:

```typescript
import esbuild from 'esbuild'
import { UniverPlugin } from '@univerjs/esbuild-plugin'
import esbuild from 'esbuild'

esbuild.build({
plugins: [
Expand Down Expand Up @@ -44,7 +44,7 @@ The plugin provides a virtual module `univer:locales`, which simplifies the impo
```typescript
import { LocaleType } from '@univerjs/core'

import { enUS, ruRU, viVN, zhCN, zhTW } from 'univer:locales'
import { enUS, faIR, ruRU, viVN, zhCN, zhTW } from 'univer:locales'

new Univer({
locales: {
Expand All @@ -53,6 +53,7 @@ new Univer({
[LocaleType.RU_RU]: ruRU,
[LocaleType.VI_VN]: viVN,
[LocaleType.ZH_TW]: zhTW,
[LocaleType.FA_IR]: faIR,
}
})
```
Expand Down
10 changes: 3 additions & 7 deletions packages/esbuild-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"build": "tsc && node ./esbuild.config.js"
},
"devDependencies": {
"@types/node": "^20.14.5",
"@types/node": "^22.7.5",
"@univerjs/plugin-core": "workspace:*",
"esbuild": "^0.21.5",
"typescript": "^5.4.5"
"esbuild": "^0.24.0",
"typescript": "^5.6.3"
}
}
1 change: 1 addition & 0 deletions packages/esbuild-plugin/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ declare module 'univer:locales' {
export const ruRU: { [key: string]: string }
export const viVN: { [key: string]: string }
export const zhTW: { [key: string]: string }
export const faIR: { [key: string]: string }
}
5 changes: 3 additions & 2 deletions packages/vite-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ npm install @univerjs/vite-plugin
Add the plugin to your `vite.config.ts`:

```typescript
import { defineConfig } from 'vite'
import { univerPlugin } from '@univerjs/vite-plugin'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
Expand Down Expand Up @@ -44,7 +44,7 @@ The plugin provides a virtual module `univer:locales`, which simplifies the impo
```typescript
import { LocaleType } from '@univerjs/core'

import { enUS, ruRU, viVN, zhCN, zhTW } from 'univer:locales'
import { enUS, faIR, ruRU, viVN, zhCN, zhTW } from 'univer:locales'

new Univer({
locales: {
Expand All @@ -53,6 +53,7 @@ new Univer({
[LocaleType.RU_RU]: ruRU,
[LocaleType.VI_VN]: viVN,
[LocaleType.ZH_TW]: zhTW,
[LocaleType.FA_IR]: faIR,
}
})
```
Expand Down
12 changes: 4 additions & 8 deletions packages/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"build": "tsc && node ./esbuild.config.js"
},
"devDependencies": {
"@types/node": "^20.14.5",
"@types/node": "^22.7.5",
"@univerjs/plugin-core": "workspace:*",
"esbuild": "^0.21.5",
"typescript": "^5.4.5",
"vite": "^5.3.1"
"esbuild": "^0.24.0",
"typescript": "^5.6.3",
"vite": "^5.4.9"
}
}
1 change: 1 addition & 0 deletions packages/vite-plugin/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ declare module 'univer:locales' {
export const ruRU: { [key: string]: string }
export const viVN: { [key: string]: string }
export const zhTW: { [key: string]: string }
export const faIR: { [key: string]: string }
}
3 changes: 2 additions & 1 deletion packages/webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The plugin provides a virtual module `univer:locales`, which simplifies the impo
```typescript
import { LocaleType } from '@univerjs/core'

import { enUS, ruRU, viVN, zhCN, zhTW } from 'univer:locales'
import { enUS, faIR, ruRU, viVN, zhCN, zhTW } from 'univer:locales'

new Univer({
locales: {
Expand All @@ -52,6 +52,7 @@ new Univer({
[LocaleType.RU_RU]: ruRU,
[LocaleType.VI_VN]: viVN,
[LocaleType.ZH_TW]: zhTW,
[LocaleType.FA_IR]: faIR,
}
})
```
Expand Down
18 changes: 9 additions & 9 deletions packages/webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
"webpack": "^4.0.0 || ^5.0.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.14.5",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.5",
"@univerjs/plugin-core": "workspace:*",
"@univerjs/ui": "0.1.15",
"css-loader": "^6.10.0",
"esbuild": "^0.21.5",
"@univerjs/ui": "0.4.0-alpha.1",
"css-loader": "^7.1.2",
"esbuild": "^0.24.0",
"jest": "^29.7.0",
"mock-fs": "^5.2.0",
"style-loader": "^3.3.4",
"ts-jest": "^29.1.5",
"typescript": "^5.4.5"
"mock-fs": "^5.4.0",
"style-loader": "^4.0.0",
"ts-jest": "^29.2.5",
"typescript": "^5.6.3"
}
}
1 change: 0 additions & 1 deletion packages/webpack-plugin/src/__tests__/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import something from '@univerjs/ui'
import { enUS, ruRU, zhCN } from 'univer:locales'

export default {
Expand Down
25 changes: 12 additions & 13 deletions packages/webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Buffer } from 'node:buffer'
import type { Compiler } from 'webpack'
import { NormalModule } from 'webpack'

import { Buffer } from 'node:buffer'
import { exportVirtualLocalesModule, virtualLocalesModuleId } from '@univerjs/plugin-core'

import { NormalModule } from 'webpack'

export interface IUniverPluginOptions {
css?: boolean
}
Expand All @@ -30,17 +30,16 @@ export class UniverPlugin {
if (NormalModule) {
// webpack 5
compiler.hooks.compilation.tap(this.name, (compilation) => {
NormalModule.getCompilationHooks(compilation).readResourceForScheme
.for(virtualLocalesModuleId.split(':')[0]).tap(this.name, (path) => {
if (path === virtualLocalesModuleId) {
if (typeof compiler.options.target === 'string' && compiler.options.target.startsWith('node')) {
return ''
}
return exportVirtualLocalesModule()
} else {
return path
NormalModule.getCompilationHooks(compilation).readResourceForScheme.for(virtualLocalesModuleId.split(':')[0]).tap(this.name, (path) => {
if (path === virtualLocalesModuleId) {
if (typeof compiler.options.target === 'string' && compiler.options.target.startsWith('node')) {
return ''
}
})
return exportVirtualLocalesModule()
} else {
return path
}
})
})
} else {
// webpack 4
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-plugin/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ declare module 'univer:locales' {
export const ruRU: { [key: string]: string }
export const viVN: { [key: string]: string }
export const zhTW: { [key: string]: string }
export const faIR: { [key: string]: string }
}
Loading
Loading