@umituz/web-localization
v1.1.16
Published
Google Translate integrated localization package for web applications
Maintainers
Readme
@umituz/web-localization 🌍
A powerful localization package for web applications with built-in automatic Google Translate integration.
🚀 Features
- Automatic Translation: Uses Google Translate API to fill in missing translations.
- Key Synchronization: Automatically syncs directory structures from a base language (e.g.,
en-US.ts) to other language files. - Deep Nesting: Supports deeply nested JSON structures for complex localization needs.
- CLI Tools: Easy-to-use command line interface for developers.
📦 Installation
npm install @umituz/web-localization🛠️ Usage
CLI Commands
First, set up your locales directory:
mkdir -p src/locales
touch src/locales/en-US.ts src/locales/tr-TR.tsSync Keys
Synchronizes all missing keys from the base language to target languages:
npx web-loc sync --locales-dir src/locales --base-lang en-USTranslate Automatically
Uses Google Translate to translate all missing keys:
npx web-loc translate --locales-dir src/locales --base-lang en-USScript Usage
You can also use the translation service directly in your scripts:
import { googleTranslateService } from "@umituz/web-localization";
await googleTranslateService.initialize({});
const response = await googleTranslateService.translate({
text: "Hello World",
targetLanguage: "tr"
});
console.log(response.translatedText); // "Merhaba Dünya"📐 Package Structure
Following the @umituz new package structure:
src/domain: Entities and Interfacessrc/infrastructure: Services, Utils, Constantssrc/presentation: Components and Hooks (React Web helpers coming soon)
Developed by umituz ⚡
