diff --git a/deno.json b/deno.json index 70b8cd74..33c8e1d6 100644 --- a/deno.json +++ b/deno.json @@ -5,6 +5,7 @@ "./packages/conf", "./packages/db", "./packages/ditto", + "./packages/lang", "./packages/metrics", "./packages/uploaders" ], diff --git a/packages/ditto/storages/EventsDB.ts b/packages/ditto/storages/EventsDB.ts index 622f5811..e7669861 100644 --- a/packages/ditto/storages/EventsDB.ts +++ b/packages/ditto/storages/EventsDB.ts @@ -1,6 +1,7 @@ // deno-lint-ignore-file require-await import { DittoTables } from '@ditto/db'; +import { detectLanguage } from '@ditto/lang'; import { NPostgres, NPostgresSchema } from '@nostrify/db'; import { dbEventsCounter } from '@ditto/metrics'; import { NIP50, NKinds, NostrEvent, NostrFilter, NSchema as n } from '@nostrify/nostrify'; @@ -18,7 +19,6 @@ import { isNostrId } from '@/utils.ts'; import { abortError } from '@/utils/abort.ts'; import { purifyEvent } from '@/utils/purify.ts'; import { DittoEvent } from '@/interfaces/DittoEvent.ts'; -import { detectLanguage } from '@/utils/language.ts'; import { getMediaLinks } from '@/utils/note.ts'; /** Function to decide whether or not to index a tag. */ diff --git a/packages/lang/deno.json b/packages/lang/deno.json new file mode 100644 index 00000000..f192fb0f --- /dev/null +++ b/packages/lang/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@ditto/lang", + "version": "1.1.0", + "exports": { + ".": "./language.ts" + } +} diff --git a/packages/ditto/utils/language.test.ts b/packages/lang/language.test.ts similarity index 98% rename from packages/ditto/utils/language.test.ts rename to packages/lang/language.test.ts index 66a26edd..09dbb66a 100644 --- a/packages/ditto/utils/language.test.ts +++ b/packages/lang/language.test.ts @@ -1,6 +1,7 @@ -import { detectLanguage } from '@/utils/language.ts'; import { assertEquals } from '@std/assert'; +import { detectLanguage } from './language.ts'; + Deno.test('Detect English language', () => { assertEquals(detectLanguage(``, 0.90), undefined); assertEquals(detectLanguage(`Good morning my fellow friends`, 0.90), 'en'); diff --git a/packages/ditto/utils/language.ts b/packages/lang/language.ts similarity index 100% rename from packages/ditto/utils/language.ts rename to packages/lang/language.ts