Skip to content

[Request] Try new ELD version 2 (Language detector), with static import. If you whish. #161

@nitotm

Description

@nitotm

🥰 需求描述 | Feature Description

Your project @lobehub/i18n-cli uses the eld fork @yutengjing/eld, which removed eld v1 top-level await and requires lazy initialization, this is what you do now:

import { eld } from '@yutengjing/eld';
...
  if (!initPromise) {
    initPromise = (async () => {
      console.log('🔧 Initializing ELD language detector...');
      await eld.init('L'); // 使用中等规模的数据集
      console.log('✅ ELD language detector initialized');
    })();
  }

I’ve published eld v2 on npm: https://www.npmjs.com/package/eld which introduces static builds, you can import a specific size directly (no init/load/await required):

import { eld } from 'eld/large'
// ready to use immediately

If needed there is still dynamic import option , if you prefer lazy loading (similar to the fork), you can still do:
(Note: the static import is preferred for simplicity and faster startup.)

import { eld } from 'eld'
await eld.load('large')

Performance & accuracy :
ELD v2 includes a notable 1.5x execution-speed improvement and modest accuracy gains.
Also eld npm install size has decreased to 9MB (from 34MB @yutengjing/eld) by removing unnecessary files.

🧐 解决方案 | Proposed Solution

import { eld } from 'eld/large'

📝 补充信息 | Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🌠 Feature RequestNew feature or request | 特性与建议

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions