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

@affiliate.fm/astro-content-ai-translator

v0.4.6

Published

Astro integration for AI-powered content translation

Readme

astro-content-ai-translator

Astro integration for AI-powered content translation using OpenAI.

Installation

npm install @affiliate.fm/astro-content-ai-translator
npx astro-ai-translator init

The setup wizard will:

  • Add integration to your astro.config.mjs
  • Set up your OpenAI API key in .env

Alternatively, use npx astro add @affiliate.fm/astro-content-ai-translator.

Quick Start

1. Mark files for translation

In your content files, add _translateTo to frontmatter:

---
title: About Us
description: Learn about our company
_translateTo: [ru, de]
---

Options:

  • _translateTo: [ru, de] — translate to specific locales
  • _translateTo: all — translate to all configured locales
  • _translateTo: false — explicitly don't translate
  • No field — file is not translated (must opt-in)

Usage

Translate missing content

npx astro-ai-translator

Before translation starts, you'll see:

  • Cost estimate — approximate tokens and USD cost
  • File list — what will be translated
  • Confirmation prompt — approve before spending API credits

Example output:

┌─────────────────────────────────────────────────────────────┐
│                   📊 TRANSLATION ESTIMATE                   │
└─────────────────────────────────────────────────────────────┘

  📁 Files to translate:
     • index.mdx → ru (~807 tokens)
     • index.mdx → ja (~807 tokens)
     • about.mdx → ru (~658 tokens)

  ─────────────────────────────────────────────────────────────
  📈 Model:          gpt-4.1
  📝 Translations:   3
  🔤 Input tokens:   ~1.1K
  📤 Output tokens:  ~1.1K
  📦 Total tokens:   ~2.3K
  ─────────────────────────────────────────────────────────────
  💰 Estimated cost: $0.02
  ─────────────────────────────────────────────────────────────

  Proceed with translation? (3 file(s), ~$0.02) [Y/n]

During translation, a live progress bar shows current status.

Translate specific file

npx astro-ai-translator about.mdx

Check status

npx astro-ai-translator --status

Preview (dry run)

npx astro-ai-translator --dry-run

Shows estimate without confirmation prompt. No API calls made.

Force overwrite

npx astro-ai-translator --force

Generated files

AI-translated files include metadata in frontmatter:

---
title: О нас
description: Узнайте о нашей компании
_ai:
  source: about.mdx
  hash: a1b2c3d4e5f6
  model: gpt-4.1
  date: "2025-12-15"
---

This lets you:

  • Identify AI translations vs manual
  • Track source file changes
  • Know which model was used

Environment variables

| Variable | Default | Description | |----------|---------|-------------| | OPENAI_API_KEY | required | OpenAI API key | | AI_TRANSLATE_MODEL | gpt-4.1 | Model override | | AI_TRANSLATE_CONTENT_DIR | src/content/pages | Content directory |

Supported models & pricing

Cost estimates use current OpenAI pricing (USD per 1M tokens):

| Model | Input | Output | Best for | |-------|-------|--------|----------| | gpt-4.1 | $2.00 | $8.00 | Default, best quality | | gpt-4.1-mini | $0.40 | $1.60 | Good balance | | gpt-4.1-nano | $0.10 | $0.40 | Budget option | | gpt-4o | $2.50 | $10.00 | High quality | | gpt-4o-mini | $0.15 | $0.60 | Very cheap | | gpt-3.5-turbo | $0.50 | $1.50 | Legacy, fast |

For high-volume translation, gpt-4.1-mini or gpt-4o-mini offer good quality at lower cost.

File structure

The translator follows Astro i18n conventions:

src/content/pages/
├── index.mdx           # Default locale (en)
├── about.mdx           # Default locale (en)
├── ru/
│   ├── index.mdx       # Russian (ai or manual)
│   └── about.mdx       # Russian (ai or manual)
└── de/
    ├── index.mdx       # German
    └── about.mdx       # German

Alternates support

If source file has alternates, translated files get correct permalink:

# Source: about.mdx
alternates:
  ru: o-nas
  de: ueber-uns

Generated ru/about.mdx will have permalink: o-nas.

Related

Author

Built by Affiliate.FM — independent media and open-source tools for affiliate, performance, and digital marketing.

License

MIT