Skip to content

ImadBL/angularjs-i18n-detector

Repository files navigation

angularjs-i18n-detector

Automatically detect and fix untranslated text in AngularJS applications. This tool scans your HTML files, detects untranslated text, adds translation attributes, and updates your JSON translation files.

Features

  • 🔍 Automatic detection of untranslated text
  • 🏷️ Automatic addition of translate attributes
  • 📝 Smart translation key generation
  • 📦 JSON translation file updates
  • 🌍 Multi-language support (default: en, fr)
  • 🔄 Preserves existing translations
  • ⚡ Fast and easy to use

Installation

npm install angularjs-i18n-detector --save-dev

Usage

Command Line

# Basic scan
npx angularjs-i18n-detector -s src/app -t src/i18n

# Specify languages (default: en,fr)
npx angularjs-i18n-detector -s src/app -t src/i18n -l en fr es

Options

  • -s, --source : Directory containing HTML files to scan
  • -t, --translations : Translation files directory
  • -l, --languages : List of languages (space-separated)

Example

Before

<div>
    <h1>Welcome to my app</h1>
    <p>Please select your language</p>
</div>

After

<div>
    <h1 translate="WELCOME_TO_MY_APP">Welcome to my app</h1>
    <p translate="PLEASE_SELECT_YOUR_LANGUAGE">Please select your language</p>
</div>

Generated Translation Files

// en.json
{
  "WELCOME_TO_MY_APP": "Welcome to my app",
  "PLEASE_SELECT_YOUR_LANGUAGE": "Please select your language"
}

// fr.json
{
  "WELCOME_TO_MY_APP": "Bienvenue sur mon application",
  "PLEASE_SELECT_YOUR_LANGUAGE": "Veuillez sélectionner votre langue"
}

How It Works

  1. Scans HTML files for untranslated text
  2. Generates translation keys from text content
  3. Adds translate attribute with generated key
  4. Updates JSON translation files
  5. Preserves existing translations
  6. Sorts keys alphabetically

Testing

npm test

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

ISC

Author

@ImadBL

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors