Skip to content

fix: use l.code instead of l.data for Lang objects in initialize#1052

Open
Oleg-cmd wants to merge 1 commit intonaptha:masterfrom
Oleg-cmd:fix/lang-object-code-property
Open

fix: use l.code instead of l.data for Lang objects in initialize#1052
Oleg-cmd wants to merge 1 commit intonaptha:masterfrom
Oleg-cmd:fix/lang-object-code-property

Conversation

@Oleg-cmd
Copy link
Copy Markdown

Problem

In src/worker-script/index.js line 238, the initialize function incorrectly uses l.data instead of l.code when converting Lang objects to a string.

Impact

This breaks the documented API for loading custom language data from memory:

createWorker([
 "eng",
 { code: "rus", data: new Uint8Array(...) }
])

Currently results in errors like:

Error opening data file ./31,139,8,8,220,55,243,92...
Failed loading language '31,139,8,8...'

The worker tries to use the binary data content as a filename instead of the code property.

     When converting Lang objects to string in the initialize function,
     the code was incorrectly using l.data (binary content) instead of
     l.code (language identifier).

     This caused errors like 'Error opening data file ./31,139,8,8...'
     when using the Lang object API with custom language data.

     Fixes the documented API usage:
     createWorker([
       'eng',
       { code: 'rus', data: languageFileData }
     ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant