AGENT SKILL

lokalise-performance-tuning

Optimize Lokalise API performance with caching, pagination, and bulk operations. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Lokalise integrations. Trigger with phrases like "lokalise performance", "optimize lokalise", "lokalise latency", "lokalise caching", "lokalise slow", "lokalise batch".

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
lokalise-performance-tuning
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Optimize Lokalise API performance with caching, pagination, and bulk operations. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Lokalise integrations. Trigger with phrases like "lokalise performance", "optimize lokalise", "lokalise latency", "lokalise caching", "lokalise slow", "lokalise batch".
allowed-tools
Read, Write, Edit
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

Lokalise Performance Tuning

Overview

Optimize Lokalise API throughput and response times for translation pipeline integrations. Lokalise enforces a global rate limit of 6 requests per second across most endpoints, making request efficiency critical for projects with thousands of keys.

Prerequisites

  • Lokalise SDK (@lokalise/node-api) or REST API access
  • Understanding of project size (key count, language count)
  • Cache layer (Redis or in-memory LRU)

Instructions

Step 1: Use Cursor Pagination with Maximum Page Size

import { LokaliseApi } from '@lokalise/node-api';
const lok = new LokaliseApi({ apiKey: process.env.LOKALISE_API_TOKEN! });

// Use cursor pagination (faster than offset for large datasets)
async function* getAllKeys(projectId: string) {
  let cursor: string | undefined;
  do {
    const result = await lok.keys().list({
      project_id: projectId,
      limit: 500,           // Maximum allowed  # HTTP 500 Internal Server Error
      pagination: 'cursor',
      cursor,
    });
    for (const key of result.items) yield key;
    cursor = result.hasNextCursor() ? result.nextCursor : undefined;
  } while (cursor);
}
// 10,000 keys: 20 API calls instead of 100 (at limit=500 vs default limit=100)  # HTTP 500 Internal Server Error

Step 2: Cache Translation Downloads

import { LRUCache } from 'lru-cache';

const downloadCache = new LRUCache<string, any>({ max: 100, ttl: 300_000 }); // 5 min

async function cachedDownload(projectId: string, format: string, langIso: string) {
  const key = `${projectId}:${format}:${langIso}`;
  const cached = downloadCache.get(key);
  if (cached) return cached;

  const bundle = await lok.files().download(projectId, {
    format, filter_langs: [langIso], original_filenames: false,
  });
  downloadCache.set(key, bundle);
  return bundle;
}

Step 3: Batch Key Operations

// Bulk create keys (up to 500 per request)  # HTTP 500 Internal Server Error
async function createKeysBatched(projectId: string, keys: any[]) {
  const BATCH_SIZE = 500;  # HTTP 500 Internal Server Error
  const results = [];
  for (let i = 0; i < keys.length; i += BATCH_SIZE) {
    const batch = keys.slice(i, i + BATCH_SIZE);
    const result = await lok.keys().create({ project_id: projectId, keys: batch });
    results.push(...result.items);
    await new Promise(r => setTimeout(r, 200)); // Respect rate limit  # HTTP 200 OK
  }
  return results;
}
// 2,000 keys: 4 batched requests vs 2,000 individual requests

Step 4: Implement Request Throttling

import PQueue from 'p-queue';

// Lokalise rate limit: 6 requests/second
const queue = new PQueue({ concurrency: 5, interval: 1000, intervalCap: 5 });  # 1000: 1 second in ms

async function throttledRequest<T>(fn: () => Promise<T>): Promise<T> {
  return queue.add(fn) as Promise<T>;
}

// All API calls go through the queue
const project = await throttledRequest(() => lok.projects().get(projectId));

Step 5: Use Webhooks Instead of Polling

set -euo pipefail
# Replace polling for translation status with webhooks
curl -X POST "https://api.lokalise.com/api2/projects/PROJECT_ID/webhooks" \
  -H "X-Api-Token: $LOKALISE_API_TOKEN" \
  -d '{
    "url": "https://hooks.company.com/lokalise",
    "events": ["project.translation_completed", "project.exported"]
  }'
# Eliminates need to poll project status every N seconds

Error Handling

Issue Cause Solution
429 Too Many Requests Exceeded 6 req/s rate limit Use PQueue throttling, retry with backoff
Slow file downloads Large project with many languages Filter by language, use async download + webhook
Pagination timeout Offset pagination on 50K+ keys Switch to cursor pagination
Bulk create fails partially Network timeout on large batch Reduce batch size to 200, add retry logic

Examples

Basic usage: Apply lokalise performance tuning to a standard project setup with default configuration options.

Advanced scenario: Customize lokalise performance tuning for production environments with multiple constraints and team-specific requirements.

Output

  • Configuration files or code changes applied to the project
  • Validation report confirming correct implementation
  • Summary of changes made and their rationale

Resources

  • Official ORM documentation
  • Community best practices and patterns
  • Related skills in this plugin pack

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0