@glang/plugin v1.0.3
g-lang
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:
- You provide your
api_key
and projectalias
- During build, g-lang fetches translations from
https://g.ars.world/<api_key>/<alias>
- Translations are injected into your application
- All translation keys are replaced with actual translations
- 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