Core
1. Install the package
npm install @lingva/core
2. Create a client instance
import { LingvaClient } from '@lingva/core';
const client = new LingvaClient({
apiUrl: 'https://api.lingva.dev/v1',
apiKey: process.env.LINGVA_API_KEY,
projectId: 'your-project-id',
// Optional: cache configuration
cache: {
ttl: 3600, // 1 hour
maxSize: 1000 // maximum items in cache
}
});
3. Use it in your code
// Fetch a translation
const welcome = await client.t('welcome.message', {
locale: 'en',
variables: { name: 'John' }
});
// Preload multiple keys
await client.preload(['common.*', 'navigation.*'], 'en');