UNPKG

@gftdcojp/weblate-nextjs-sdk

Version:

A Next.js SDK for integrating with Weblate translation management system

135 lines (134 loc) 3.38 kB
export interface WeblateConfig { baseUrl: string; apiKey: string; timeout?: number; retries?: number; } export interface WeblateProject { id: string; name: string; slug: string; description: string; web: string; language_code: string; languages: WeblateLanguage[]; components: WeblateComponent[]; } export interface WeblateComponent { id: string; name: string; slug: string; project: string; repository: string; branch: string; file_format: string; filemask: string; template: string; license: string; agreement: string; new_lang: string; language_code: string; languages: WeblateLanguage[]; stats: WeblateStats; } export interface WeblateLanguage { id: string; code: string; name: string; native_name: string; direction: 'ltr' | 'rtl'; plural: { number: number; formula: string; }; statistics: WeblateStats; } export interface WeblateStats { total: number; translated: number; fuzzy: number; failing: number; failing_percent: number; translated_percent: number; fuzzy_percent: number; approved: number; approved_percent: number; readonly: number; readonly_percent: number; suggestions: number; comments: number; last_change: string; last_author: string; } export interface WeblateTranslation { id: string; component: string; language: string; filename: string; revision: string; web_url: string; share_url: string; translate_url: string; repository_url: string; statistics: WeblateStats; } export interface WeblateUnit { id: string; translation: string; source: string; target: string; context: string; note: string; flags: string; fuzzy: boolean; translated: boolean; approved: boolean; readonly: boolean; position: number; timestamp: string; last_updated: string; } export interface WeblateApiResponse<T> { data: T; count?: number; next?: string; previous?: string; } export interface WeblateError { error: string; message: string; code?: number; } export interface TranslationHookResult { translations: Record<string, string>; isLoading: boolean; error: WeblateError | null; mutate: () => void; } export interface LanguageHookResult { languages: WeblateLanguage[]; currentLanguage: WeblateLanguage | null; isLoading: boolean; error: WeblateError | null; setLanguage: (languageCode: string) => void; } export interface WeblateClient { getProjects(): Promise<WeblateProject[]>; getProject(slug: string): Promise<WeblateProject>; getComponents(projectSlug: string): Promise<WeblateComponent[]>; getTranslations(componentSlug: string): Promise<WeblateTranslation[]>; getTranslation(componentSlug: string, languageCode: string): Promise<WeblateTranslation>; getUnits(translationId: string): Promise<WeblateUnit[]>; updateUnit(unitId: string, target: string): Promise<WeblateUnit>; } export interface WeblateContextValue { config: WeblateConfig; currentLanguage: string; setLanguage: (languageCode: string) => void; client: WeblateClient; } export interface WeblateProviderProps { children: any; config: WeblateConfig; defaultLanguage?: string; }