-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
3,324 additions
and
2,882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { generateRandomString } from './utils' | ||
|
||
export const virtualLocalesModuleId = 'univer:locales' | ||
|
||
/** | ||
* Generates a virtual module that exports all the locales from `@univerjs` and `@univerjs-pro`. | ||
* | ||
* @returns {string} A string containing the import and export statements for all the locales from `@univerjs` and `@univerjs-pro`. | ||
*/ | ||
export function exportVirtualLocalesModule() { | ||
const scopes = ['@univerjs', '@univerjs-pro'] | ||
|
||
const languages = ['en-US', 'ru-RU', 'zh-CN', 'vi-VN', 'zh-TW', 'fa-IR'].reduce((acc, lang) => { | ||
acc[lang] = new Set() | ||
return acc | ||
}, {}) | ||
|
||
let importStatement = `import { Tools as _Tools } from '@univerjs/core';\n` | ||
let exportStatement = '' | ||
|
||
for (const scope of scopes) { | ||
const scopePath = path.resolve('node_modules', scope) | ||
if (fs.existsSync(scopePath)) { | ||
const packagePaths = fs.readdirSync(scopePath) | ||
|
||
for (const packagePath of packagePaths) { | ||
const packageName = `${scope}/${packagePath}` | ||
|
||
Object.keys(languages).forEach((lang) => { | ||
const langPath = path.resolve('node_modules', packageName, 'lib/types/locale', `${lang}.d.ts`) | ||
|
||
if (fs.existsSync(langPath)) { | ||
const langVar = `${lang.replace('-', '')}` | ||
|
||
const key = `${generateRandomString(8)}${langVar}` | ||
importStatement += `import ${key} from '${packageName}/lib/locale/${lang}';\n` | ||
languages[lang].add(key) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
Object.keys(languages).forEach((lang) => { | ||
const langVar = `${lang.replace('-', '')}` | ||
|
||
if (languages[lang].size > 0) { | ||
exportStatement += `export const ${langVar} = _Tools.deepMerge(` | ||
|
||
languages[lang].forEach((key) => { | ||
exportStatement += `${key},\n` | ||
}) | ||
|
||
exportStatement += `);\n` | ||
} | ||
}) | ||
|
||
return importStatement + exportStatement | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.