1.0.3 โ€ข Published 6 months ago

@glang/plugin v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

g-lang

npm version License: MIT npm downloads Tests Coverage

A build-time localization solution for modern JavaScript frameworks that automatically fetches and injects translations during the build process.

โœจ Features

  • Zero-runtime localization - Translations are injected at build time
  • Simple integration - Works seamlessly with Next.js and Nuxt.js
  • Centralized management - Translations stored on g.ars.world
  • Automatic updates - Fetch latest translations on each build
  • Lightweight - No heavy client-side libraries

๐Ÿš€ How It Works

g-lang connects to the g.ars.world translation service during your build process:

  1. You provide your api_key and project alias
  2. During build, g-lang fetches translations from https://g.ars.world/<api_key>/<alias>
  3. Translations are injected into your application
  4. All translation keys are replaced with actual translations
  5. The built application contains all translations statically

This approach eliminates the need for client-side translation loading and reduces bundle size.

๐Ÿ“ฆ Installation

npm install @glang/plugin
# or
yarn add @glang/plugin

๐Ÿ”ง Usage

For Next.js

// next.config.js
const Glang = require('@glang/plugin');

module.exports = {
  // ... other config
  plugins: [
    Glang.nextPlugin({
      api_key: 'your_api_key',
      alias: 'your_project_alias',
      outputDir: 'public/locales' // Optional
    })
  ]
};

For Vite

// vite.config.js
import { defineConfig } from 'vite';
import Glang from '@glang/plugin';

export default defineConfig({
  plugins: [
    Glang.vitePlugin({
      api_key: 'your_api_key',
      alias: 'your_project_alias',
      outputDir: 'public/locales' // Optional
    })
  ]
});

For webpack

// webpack.config.js
const Glang = require('@glang/plugin');

module.exports = {
  plugins: [
    new Glang.webpackPlugin({
      api_key: 'your_api_key',
      alias: 'your_project_alias',
      outputDir: 'public/locales' // Optional
    })
  ]
};

For Nuxt.js

// nuxt.config.js
export default defineNuxtConfig({
  // ... other config
  modules: [
    ['@glang/plugin', {
      api_key: 'your_api_key',
      alias: 'your_project_alias',
      outputDir: 'public/locales' // Optional
    }]
  ]
})

Configuration

  • api_key (required) - Your account API key from g.ars.world
  • alias (required) - Your project alias

๐ŸŒ Multi-language Support

g-lang automatically handles multi-language projects. Your translations should be structured with language codes as top-level keys:

{
  "en": {
    "welcome": "Welcome",
    "about": "About Us"
  },
  "fr": {
    "welcome": "Bienvenue",
    "about": "ร€ propos"
  }
}

๐Ÿงช Testing

The codebase is thoroughly tested to ensure reliability:

  • Unit tests with Jest/Vitest
  • Integration tests for all major frameworks
  • End-to-end testing for critical workflows
  • Code coverage maintained at 90%+

To run tests locally:

npm test
# or
yarn test

๐Ÿ’ก Best Practices

Use meaningful keys - Choose translation keys that describe their purpose

Keep translations organized - Group related translations together

Update regularly - Fetch fresh translations during your build process

Fallback language - Always provide complete translations for your default language

Cache wisely - Balance between build performance and translation freshness

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

Fork the repository

Create your feature branch (git checkout -b feature/AmazingFeature)

Commit your changes (git commit -m 'Add some AmazingFeature')

Push to the branch (git push origin feature/AmazingFeature)

Open a Pull Request

๐Ÿ“œ License

Distributed under the MIT License. See LICENSE for more information.

๐Ÿ“ง Contact

For support or questions, contact us at support@ars.world

๐Ÿ™ Credits

Developed by ARS33 Inspired by modern localization needs Built with โค๏ธ for the open source community

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago