Custom Spellchecker
This module allows you to add custom spellcheckers to verify translations against specific rules that are not supported by default.
Custom Spellchecker Module Read more on the Crowdin Developer Portal.
Sample
Section titled “Sample”const crowdinModule = require('@crowdin/app-project-module');
const configuration = { baseUrl: 'https://123.ngrok.io', clientId: 'clientId', clientSecret: 'clientSecret', name: 'Sample App', identifier: 'sample-app', description: 'Sample App description', dbFolder: __dirname, imagePath: __dirname + '/' + 'logo.png', customSpellchecker: { getSupportedLanguage: async ({ client, context }) => { return [ { code: 'en', name: 'English' }, { code: 'uk', name: 'Ukrainian' } ]; }, runSpellCheck: async ({ client, context, language, texts }) => { // language = 'en'; // texts = [ 'I have an appple', 'And many oranges' ]; // some spelling logic return { texts: [ { text: 'I have an appple', matches: [ { category: 'typos', message: 'Found a grammar error', shortMessage: 'Grammar error', offset: 10, length: 6, replacements: [ 'apple' ] } ] }, { text: 'And many oranges', matches: [] } ] } } }};
crowdinModule.createApp(configuration);Configuration
Section titled “Configuration”The custom spellchecker application requires implementation of two functions to work properly.
getSupportedLanguage Function
Section titled “getSupportedLanguage Function”Called when retrieving the list of languages supported by the custom spellchecker.
Parameters
Section titled “Parameters”client- Crowdin API client.context- Context object.
Return Value
Section titled “Return Value”An array of objects with the following structure:
{ code: string, name: string}runSpellCheck Function
Section titled “runSpellCheck Function”Called when running the spellchecker against the provided texts.
Parameters
Section titled “Parameters”client- Crowdin API client.context- Context object.language- Language code.texts- Array of texts to check.
Return Value
Section titled “Return Value”It should return an object with the following structure:
{ texts: [ { text: string, matches: [ { category: string, message: string, shortMessage: string, offset: number, length: number, replacements: string[] } ] } ]}Read more about available categories.