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

@rareformlabs/vue3-gettext

v4.3.1

Published

Translate Vue 3 applications with gettext (maintained fork)

Readme

Translate Vue 3 applications with gettext.

Install

npm i @rareformlabs/vue3-gettext

Basic usage

In templates:

<span>
  {{ $gettext("I'm %{age} years old!", { age: 32 }) }}
</span>

In code:

const { $gettext } = useGettext();

console.log($gettext("Hello World!"));

Features

  • simple, ergonomic API
  • reactive translations in Vue templates and TypeScript/JavaScript code
  • CLI to automatically extract messages from code files
  • AI-assisted PO translation for missing entries
  • support for pluralization and message contexts

Extraction, Translation & Configuration

This fork includes improved extraction tools with configurable location comments, auto-filling support, and optional AI-assisted translation.

Create a gettext.config.js in your project root:

export default {
  input: {
    path: "./src",
    include: ["**/*.js", "**/*.ts", "**/*.vue"],
    exclude: [],
  },
  output: {
    path: "./src/language",
    locales: ["en", "es"],
    /**
     * "full": file and line number (default)
     * "file": filename only (reduces merge conflicts)
     * "never": no location comments
     */
    addLocation: "file",
    /**
     * If true, empty msgstr entries in PO files will be filled with the msgid.
     * Can also be an array of locales to auto-fill (e.g. ["en"]).
     * Useful for mechanical default locales (e.g. English).
     */
    autoFill: ["en"],
  },
  translate: {
    provider: "openai",
    model: "gpt-4.1-mini", // default translation model
    // optional: limit translation to specific locales instead of output.locales
    locales: ["es"],
    // default false: only fill missing entries; true means retranslate existing msgstr values too
    includeTranslated: false,
    openai: {
      /**
       * Default: "api-key"
       * - "api-key" uses https://api.openai.com/v1/chat/completions
       * - "oauth" uses ChatGPT/Codex OAuth via @mariozechner/pi-ai and https://chatgpt.com/backend-api/codex/responses
       */
      authMode: "api-key",
      // optional override, defaults to OPENAI_API_KEY
      apiKeyEnvVar: "OPENAI_API_KEY",
      // advanced: override the API base URL; normally leave unset
      baseUrl: undefined,
    },
  },
};

OAuth mode example:

export default {
  translate: {
    provider: "openai",
    model: "gpt-5.4",
    includeTranslated: false,
    openai: {
      authMode: "oauth",
      // where vue-gettext reads/writes saved OAuth credentials
      // defaults to ~/.vue-gettext/openai-codex-oauth.json
      credentialsPath: "./.gettext/openai-codex-oauth.json",
      // SECURITY WARNING: Do not commit OAuth credentials to version control!
      // 1. Add credentialsPath to .gitignore (e.g., echo ".gettext/" >> .gitignore)
      // 2. Restrict file permissions (e.g., chmod 600 ./.gettext/openai-codex-oauth.json)
      // 3. Consider using env var overrides below to avoid storing tokens on disk
      // optional env overrides if you do not want a file
      accessTokenEnvVar: "OPENAI_OAUTH_ACCESS_TOKEN",
      refreshTokenEnvVar: "OPENAI_OAUTH_REFRESH_TOKEN",
      accountIdEnvVar: "OPENAI_OAUTH_ACCOUNT_ID",
      // if a refresh occurs, save the updated credentials back to credentialsPath
      persistRefresh: true,
      // advanced: override the backend endpoint; normally leave unset
      baseUrl: undefined,
      // advanced: override the OAuth originator header only if your environment needs it
      originator: undefined,
    },
  },
};

Credential file formats accepted in OAuth mode:

SECURITY WARNING: Do not commit OAuth credentials to version control!

  • Add the credentials file to .gitignore (e.g., echo ".gettext/" >> .gitignore)
  • Restrict file permissions (e.g., chmod 600 ./.gettext/openai-codex-oauth.json)
  • Alternative: Use environment variable overrides (accessTokenEnvVar, refreshTokenEnvVar, accountIdEnvVar) to avoid storing tokens on disk
{
  "access": "<token>",
  "refresh": "<token>",
  "expires": 1760000000000,
  "accountId": "user-123"
}

or:

{
  "openai-codex": {
    "access": "<token>",
    "refresh": "<token>",
    "expires": 1760000000000,
    "accountId": "user-123"
  }
}

Run extraction:

npx vue-gettext-extract

Run AI translation for missing entries with API key auth:

OPENAI_API_KEY=your-key npx vue-gettext-translate

Run AI translation with OAuth auth:

OPENAI_OAUTH_ACCESS_TOKEN=... \
OPENAI_OAUTH_REFRESH_TOKEN=... \
OPENAI_OAUTH_ACCOUNT_ID=... \
npx vue-gettext-translate

Or point translate.openai.credentialsPath at a saved OAuth JSON file.

Login helper for OAuth:

npx vue-gettext-openai-login

Run compilation:

npx vue-gettext-compile

Contribute

Note: We're publishing a stable 4.1.1 next (dropping the beta suffix).

Please make sure your code is properly formatted (the project contains a prettier config) and all the tests run successfully (npm run test) when opening a pull request.

Please specify clearly what you changed and why.

Credits

This plugin relies heavily on the work of the original vue-gettext.

License

MIT