惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I stopped my README.md and README.zh.md from drifting...
Alexander A. · 2026-05-04 · via DEV Community

The drift problem

Every project that ships a translated README has the same lifecycle:

  1. Someone writes README.md in English.
  2. A contributor opens a PR with README.zh.md. Great.
  3. Three months later, English has six new sections. Chinese has the original.
  4. A second translator opens README.es.md. Spanish gets translated from… which version? The current README.md? Or README.zh.md, by accident, because the structure looks tidier?
  5. By month nine, you have three READMEs that disagree on what the project actually is.

You can't tell at a glance which file is stale. Reviewers don't read all three. Translations rot, and there's nothing forcing them to stay in sync.

I got tired of this and built a small Java tool — NRG — to fix it. Looking for honest feedback while it's still small enough to change direction.

The idea: one source, N outputs

Write one README.src.md. Get back README.md, README.zh.md, README.ja.md, and as many language variants as you list.

Lines in the template fall into three categories:

Shared across all languages (badges, code blocks, file paths, anything language-agnostic) — no markup needed, the line just appears in every output:

![CI](https://img.shields.io/github/actions/workflow/status/owner/repo/ci.yml)

Enter fullscreen mode Exit fullscreen mode

Language-tagged — appears only in that language's output:

This library is small but hard to use.<!--en-->
Эта библиотека маленькая, но сложная в использовании.<!--ru-->
本库虽小,但难以使用。<!--zh-->

Enter fullscreen mode Exit fullscreen mode

Inline per-language phrases — useful for short strings like anchor names or button labels where one full line per language would be overkill:

## ${en:'Table of contents', ru:'Содержание', zh:'目录'}

Enter fullscreen mode Exit fullscreen mode

Run nrg -f README.src.md. Out come README.md, README.ru.md, README.zh.md, all stamped with a header comment so a reader knows the file is generated.

The killer feature: CI drift-check

This is the part I actually care about, and the reason "regenerate the file periodically" wasn't enough.

NRG ships a GitHub Action (nanolaba/nrg-action@v1) with a check mode. On every PR, it regenerates the READMEs into a temp dir and diffs them against what's committed. If they don't match, the build fails with a unified diff:

--- README.md (on disk)
+++ README.md (generated)
@@ line 27 @@
-## Quick start
+## Getting started

Enter fullscreen mode Exit fullscreen mode

That means a contributor can't land a hand-edit to README.zh.md that bypasses the template. Either they edit README.src.md and regenerate, or CI rejects the PR. No more silent drift.

The CLI has the same flag: nrg -f README.src.md --check. Useful in pre-commit hooks.

Built-in widgets

Anything the template syntax can't express directly is a widget. The shipped set:

  • ${widget:tableOfContents(ordered='true')} — auto-builds a TOC from heading levels.
  • ${widget:import(path='docs/intro.src.md')} — composes templates so a giant README isn't one 800-line file.
  • ${widget:exec(cmd='git rev-parse --short HEAD')} — embeds shell output (handy for "last built from commit X").
  • ${widget:fileTree(path='src/main/java', depth='2')} — auto-generates a directory tree.
  • ${widget:math(expr='\\pi r^2')} — renders LaTeX, with an SVG fallback for the cases where GitHub's native MathJax silently fails.
  • Plus alert, badge, if/endIf, date, todo.

Custom widgets are a one-class implementation of an NRGWidget interface — useful if you have a recurring pattern specific to your project (e.g. a "feature matrix" widget that renders a row per supported runtime).

Three integration modes

CLInrg -f README.src.md. Zero config beyond declaring <!--@nrg.languages=en,ru,zh--> in the template.

Maven plugin — for Java projects, hangs off the compile phase, regenerates on every build:

<plugin>
    <groupId>com.nanolaba</groupId>
    <artifactId>nrg-maven-plugin</artifactId>
    <version>1.2</version>
    <configuration>
        <file><item>README.src.md</item></file>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals><goal>create-files</goal></goals>
        </execution>
    </executions>
</plugin>

Enter fullscreen mode Exit fullscreen mode

GitHub Action — for Python, JS, Rust, or any non-Java project. The action provisions Java itself, so you don't need a Java toolchain in your repo:

- uses: nanolaba/nrg-action@v1
  with:
    file: README.src.md
    mode: check

Enter fullscreen mode Exit fullscreen mode

That's the whole setup. There's also a Java library mode if you want to embed it in some other generator pipeline.

Honest limitations

  • Java 8 minimum — the binary's portable, but if you despise installing JDKs, the GitHub Action route is the only zero-touch option.
  • Not a translation tool. NRG keeps structure synchronized. Actual prose translation is still a human job (or your favourite LLM).
  • No Markdown AST. Substitution and widgets operate on raw text. This is fine 99% of the time but means a clever author can produce broken Markdown that NRG won't catch — that's why there's a separate validate mode.
  • Early days. Currently at v1.2, used by a handful of open-source repos. The widget API may still change.

What I'd love feedback on

  1. Drift-check workflow — useful safety net, or annoying friction when a translator just wants to fix a typo? Curious how this lands for people who maintain translated docs at scale.
  2. Widget syntax${widget:tableOfContents(title='...', ordered='true')} — readable, or have I reinvented a worse Mustache?
  3. What would actually make you adopt this over your current setup (hand-syncing, custom script, doing nothing)? "I'd never use this because…" answers are the most useful.

Repo, full docs, and the GIF demo: github.com/nanolaba/readme-generator

Thanks for reading — happy to answer questions in the comments.