npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@translation-cms/sync

v1.2.132

Published

Scan translation keys in your codebase and sync them to the Translations CMS

Readme

@translation-cms/sync

Scan translation keys in je codebase en sync ze naar de Translations CMS. Haul vertalingen automatisch op in dev-mode via Next.js plugin. Gebouwd voor Next.js

  • i18next met full TypeScript support.

Hoe werkt het?

| Wat | Waar | Hoe | | -------------------- | --------------------------------- | -------------------------------- | | Pull vertalingen | Build pipeline (next build) | Plugin (automatisch) | | Scan + sync keys | CI/CD pipeline (na merge develop) | CLI (sync-translations sync) | | Status check | Lokale dev | CLI (sync-translations status) |


Setup

Stap 1: Installeren

pnpm add @translation-cms/sync
pnpm add i18next react-i18next i18next-resources-to-backend

Stap 2: Configuratie

Creëer .translationsrc.json in je project root:

{
    "cmsUrl": "https://cms.example.nl",
    "outputDir": "src/lib/i18n/dictionaries"
}

Voeg je API key toe aan .env.local:

CMS_SYNC_API_KEY=eyJ...

Zoek je API key? In de CMS: Project Settings → Environments → jouw environment → API Key

Opmerking: projectId wordt automatisch uit de API key geëxtraheerd. Je hoeft het niet handmatig in te voeren of op te slaan.

Stap 3: Plugin in next.config.ts

import withTranslationsCMS from '@translation-cms/sync/next';
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {};

export default withTranslationsCMS(nextConfig);

Automatische workflow per omgeving:

| Omgeving | Commando | Wat de plugin doet | | ---------------- | ----------------------------------- | ------------------------------ | | Development | pnpm dev | ❌ Niks (geen pull/sync) | | Staging build | ENVIRONMENT=staging pnpm build | ✅ Sync keys (upload naar CMS) | | Production build | ENVIRONMENT=production pnpm build | ✅ Pull vertalingen |

De plugin detecteert automatisch of je aan het bouwen bent en welke omgeving (staging vs production) je target. Pull vertalingen moet handmatig gebeuren met pnpm sync-translations pull.

Stap 4: i18n Setup

Voeg de provider toe aan src/app/layout.tsx:

import { TranslationProvider } from '@/lib/i18n/provider';

export default function RootLayout({
    children,
}: {
    children: React.ReactNode;
}) {
    return (
        <html>
            <body>
                <TranslationProvider>{children}</TranslationProvider>
            </body>
        </html>
    );
}

Vertalingen gebruiken in je app

Server Component

import { getTranslation } from '@/lib/i18n/server';

export default async function Page() {
    const { t } = await getTranslation('common');
    return <h1>{t('common:app.title')}</h1>;
}

Client Component

'use client';
import { useTranslation } from '@/lib/i18n/client';

export function MyButton() {
    const { t } = useTranslation('common');
    return <button>{t('common:button.click')}</button>;
}

Meerdere namespaces

const { t } = useTranslation(['common', 'auth']);

t('common:nav.home'); // ✓
t('auth:login.email'); // ✓
t('payments:amount'); // TypeScript-fout — namespace niet geladen

CLI Commands

Voor project scanning, syncing, en CI/CD pipelines:

# Scan keys en upload naar CMS
sync-translations sync

# Download gepubliceerde vertalingen
sync-translations pull

# Zie wat veranderd is (lokaal, geen netwerk)
sync-translations status

# Eenmalige setup (manueel config-generator)
sync-translations init

# Bypass cache, altijd opnieuw laden
sync-translations pull --force

# Toon wat zou veranderen zonder uit te voeren
sync-translations sync --dry-run

# Aangepaste output-map
sync-translations pull --output ./translations

# Specifieke omgeving (staging/production)
sync-translations pull --env staging

Handige flags:

| Flag | Beschrijving | | ---------------- | ---------------------------------------------------------- | | --force | TTL cache negeren, altijd opnieuw ophalen | | --dry-run | Toon wijzigingen, voer niet uit (sync) | | --output <dir> | Aangepaste output-map voor JSON | | --env <naam> | Pull van specifieke omgeving | | --ttl <ms> | Cache TTL in milliseconden | | --project-id | Projectnummer (optioneel — wordt uit API key geëxtraheerd) |


Programmatic API

Voor custom scripts en CI/CD workflows:

import {
    syncTranslations,
    pullTranslations,
    watchTranslations,
} from '@translation-cms/sync/api';

// Keys scannen en uploaden naar CMS
await syncTranslations({
    projectRoot: '.',
    verbose: true,
});

// Vertalingen ophalen en naar disk schrijven
await pullTranslations({
    cmsUrl: process.env.CMS_URL,
    projectId: process.env.CMS_PROJECT_ID,
    apiKey: process.env.CMS_SYNC_API_KEY,
    outputDir: 'src/lib/i18n/dictionaries',
    force: false, // skip cache als true
});

// Optioneel: polling voor CMS-updates
watchTranslations({
    checkInterval: 300_000, // elke 5 minuten
});

Troubleshooting

| Probleem | Oplossing | | -------------------------------- | --------------------------------------------------------------- | | Geen keys gevonden | Zorg dat je t('namespace:key') gebruikt — namespace verplicht | | Plugin haalt niet op | Check .translationsrc.json: cmsUrl, projectId ingesteld | | CMS_SYNC_API_KEY niet herkend | Herstart dev server na wijzigen van .env.local | | Pull mislukt (credentials error) | Controleer API key in CMS Project Settings | | Cache stale (oude vertalingen) | Gebruik sync-translations pull --force om te flushen | | Wil preview van wijzigingen | sync-translations sync --dry-run toont wat zou veranderen |


Best practices

  • ✅ Commit .translationsrc.json — dit is shared config (bevat geen projectId meer)
  • ❌ Commit .env.local NIET — bevat API keys
  • Voeg toe aan .gitignore:
    .env.local
    .cms-sync-cache.json
    .cms-sync-cache-meta.json
  • Gebruik server components waar mogelijk — beter voor performance
  • Keys scannen gebeurt automatisch in CI/CD — developers hoeven niks handmatig
  • Lokale development: sync-translations pull handmatig draaien of pullOnDev: true in next.config.ts

Workflow voor je team

Developers (Lokaal):

  1. Voeg t('namespace:key') toe in code
  2. Run pnpm dev (plugin doet NIKS)
  3. Handmatig vertalingen ophalen: pnpm sync-translations pull
  4. Push naar develop

CI/CD Pipeline (Staging build):

  1. ENVIRONMENT=staging pnpm build
  2. Plugin draait: sync keys (upload naar CMS)
  3. Vervolgens: pnpm sync-translations pull --env staging (fetch vertalingen)
  4. Build artifact klaar voor testing

CI/CD Pipeline (Production build):

  1. ENVIRONMENT=production pnpm build
  2. Plugin draait: pull vertalingen (van gepubliceerde CMS release)
  3. Build artifact klaar voor live

Editors (CMS):

  1. Vul/edit vertalingen in CMS
  2. Publiceer naar staging → production
  3. Production build getriggerd automatisch

MIT License