UNPKG

@crowdin/app-project-module

Version:

Module that generates for you all common endpoints for serving standalone Crowdin App

57 lines (56 loc) 1.67 kB
import Crowdin from '@crowdin/crowdin-api-client'; import { CrowdinContextInfo, Environments, ModuleKey, UiModule } from '../../types'; export interface CustomSpellCheckRequest { language: string; texts: string[]; } export type SpellCheckCategory = 'typography' | 'casing' | 'grammar' | 'typos' | 'punctuation' | 'confused_words' | 'redundancy' | 'style' | 'gender_neutrality' | 'semantics' | 'colloquialisms' | 'wikipedia' | 'barbarism' | 'misc'; export interface SupportedLanguage { code: string; name: string; } export interface SpellCheckMatch { category: SpellCheckCategory; message: string; shortMessage: string; offset: number; length: number; replacements: string[]; } export interface CustomSpellCheckResponse { texts: { text: string; matches: SpellCheckMatch[]; }[]; error?: string; } export interface CustomSpellcheckerModule extends Environments, ModuleKey { /** * module description */ description?: string; /** * module name */ name?: string; /** * Settings UI module */ settingsUiModule?: UiModule; /** * function to get list of supported languages that are supports by current spellchecker */ getSupportedLanguage: ({ client, context, }: { client?: Crowdin; context?: CrowdinContextInfo; }) => Promise<SupportedLanguage[]>; /** * function to check spelling */ runSpellCheck: ({ client, context, language, texts, }: { client?: Crowdin; context?: CrowdinContextInfo; language: string; texts: string[]; }) => Promise<CustomSpellCheckResponse>; }