PHPackages                             nativemind/wp-translation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. nativemind/wp-translation

ActiveWordpress-plugin[Caching](/categories/caching)

nativemind/wp-translation
=========================

Advanced WordPress translation plugin with Polylang integration, caching, and multisite support

v1.0.0(7mo ago)20MITPHPPHP &gt;=7.4

Since Sep 21Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/libsPHP/wp-translation)[ Packagist](https://packagist.org/packages/nativemind/wp-translation)[ Docs](https://nativemind.net)[ RSS](/packages/nativemind-wp-translation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

NativeLang WordPress Plugin
===========================

[](#nativelang-wordpress-plugin)

**Empowering Multilingual WordPress Sites with Advanced Translation Capabilities**

NativeLang is a comprehensive WordPress plugin designed to significantly enhance your website's multilingual capabilities. Built as an advanced extension for the popular Polylang plugin, NativeLang adds powerful translation features, intelligent caching, and seamless multisite support that make it easier than ever to manage and deliver content in multiple languages.

🚀 Key Features
--------------

[](#-key-features)

### Core Translation Features

[](#core-translation-features)

- **🔄 Automatic Content Translation:** Real-time translation of posts, pages, titles, and widgets using Google Translate API
- **🎯 Smart Menu Translation:** Automatic translation of navigation menus with emoji support and custom mappings
- **🧠 Intelligent Caching:** Advanced caching system with automatic expiration and cleanup to reduce API calls
- **📊 Translation Quality Control:** Built-in quality assessment with metrics and error handling

### User Interface &amp; Experience

[](#user-interface--experience)

- **🌍 Language Switcher Widget:** Customizable language switcher with flags, dropdowns, and multiple display options
- **🎨 Emoji Support:** Rich emoji integration for enhanced visual language identification
- **📱 Responsive Design:** Mobile-optimized interface with accessibility features
- **⚡ Real-time Updates:** Live translation status with progress indicators

### Advanced Features

[](#advanced-features)

- **🏢 Multisite Support:** Full WordPress Multisite compatibility with domain mapping
- **🔧 Developer-Friendly:** Extensive hooks, filters, and APIs for customization
- **📈 Performance Optimized:** Minimal database queries with intelligent memory management
- **🛡️ Security Focused:** Secure cache handling with proper sanitization and validation

### Administrative Tools

[](#administrative-tools)

- **⚙️ Admin Dashboard:** Comprehensive settings page with cache management and statistics
- **📊 Analytics:** Detailed translation metrics and performance monitoring
- **🔄 Bulk Operations:** Mass cache clearing and translation management
- **🧪 Testing Suite:** Built-in test framework for validation and debugging

📦 Architecture Overview
-----------------------

[](#-architecture-overview)

NativeLang follows a modular architecture designed for performance, maintainability, and extensibility:

### Core Components

[](#core-components)

- **🏗️ Main Plugin Class (`NativeMind`):** Singleton pattern with comprehensive hook management
- **💾 Cache System (`NativeMindCache`):** Advanced file-based caching with automatic cleanup
- **🌐 Internationalization (`i18n.php`):** Complete language support with Polylang integration
- **🔧 Utility Functions (`functions.php`):** Helper functions for common operations
- **🌍 Multisite Support (`multisite/`):** Domain mapping and multi-language site management

### Integration Points

[](#integration-points)

- **WordPress Core:** Deep integration with WordPress hooks and filters
- **Polylang Plugin:** Seamless extension of Polylang's capabilities
- **Google Translate API:** Reliable translation service with fallback handling
- **WordPress Multisite:** Native support for network installations

🛠️ Installation &amp; Setup
---------------------------

[](#️-installation--setup)

### Prerequisites

[](#prerequisites)

- WordPress 5.0 or higher
- PHP 7.4 or higher
- Polylang plugin installed and activated
- Google Translate API key (for automatic translations)

### Installation Methods

[](#installation-methods)

#### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer require nativemind/wp-translation
```

#### Manual Installation

[](#manual-installation)

1. **Download Plugin Files:**

    ```
    # Download and extract to your WordPress plugins directory
    /wp-content/plugins/nativemind-wp-translation/
    ```
2. **Configure Polylang:**

    - Install and activate Polylang
    - Set up your languages in Polylang settings
    - Configure default language
3. **Activate NativeLang:**

    - Go to WordPress Admin → Plugins
    - Activate "NativeMind Plugin"
4. **Configure API Key:**

    **Option 1: Environment Variable (Recommended)**

    ```
    # Set in your server environment or wp-config.php
    define('GOOGLE_TRANSLATE_API_KEY', 'your-api-key-here');
    ```

    **Option 2: Copy Template File**

    ```
    # Copy the template and add your API key
    cp translateTextGoogle.php.example translateTextGoogle.php
    # Edit translateTextGoogle.php and add your API key
    ```
5. **Multisite Setup (Optional):**

    ```
    // Edit multisite/my_domains.php
    cybo_add_extra_domain( 'your-domain.com', '/', 1 );
    ```

🎯 Usage Guide
-------------

[](#-usage-guide)

### Basic Usage

[](#basic-usage)

#### Language Switcher

[](#language-switcher)

Add language switcher anywhere using:

**Shortcode:**

```
[nm_language_switcher show_flags="true" show_names="true" dropdown="false"]
```

**PHP Function:**

```
echo nm_get_language_switcher(array(
    'show_flags' => true,
    'show_names' => true,
    'dropdown' => false
));
```

**Widget:**

- Go to Appearance → Widgets
- Add "NativeMind Language Switcher" widget

#### Menu Translation

[](#menu-translation)

- Create menus in WordPress as usual
- Use `#LANGUAGE#` placeholder for current language display
- Add emojis to menu items for visual enhancement

### Advanced Configuration

[](#advanced-configuration)

#### Custom Translation Mappings

[](#custom-translation-mappings)

```
// Add to i18n/menu/custom.php
$nm_custom = array(
    'en' => array(
        'Home' => 'Home',
        'About' => 'About Us'
    ),
    'ru' => array(
        'Home' => 'Главная',
        'About' => 'О нас'
    )
);
```

#### Cache Management

[](#cache-management)

```
// Clear all cache
$cleared = NativeMindCache::clear_all();

// Get cache statistics
$stats = NativeMindCache::get_stats();

// Manual cache control
$cache_key = NativeMindCache::generate_cache_key($content, 'en', 'ru');
NativeMindCache::set($cache_key, $translated_content);
```

#### Multisite Domain Mapping

[](#multisite-domain-mapping)

```
// Configure in multisite/my_domains.php
cybo_add_extra_domain( 'en.example.com', '/', 1 );  // English site
cybo_add_extra_domain( 'ru.example.com', '/', 2 );  // Russian site
cybo_add_extra_domain( 'example.ru', '/', 2 );      // Alternative Russian domain
```

🔧 Developer API
---------------

[](#-developer-api)

### Hooks and Filters

[](#hooks-and-filters)

#### Actions

[](#actions)

```
// Plugin initialization
do_action('nm_plugin_loaded');

// Translation events
do_action('nm_translation_start', $content, $from_lang, $to_lang);
do_action('nm_translation_complete', $translated_content, $original_content);
do_action('nm_translation_error', $error_message, $content);

// Cache events
do_action('nm_cache_cleared');
do_action('nm_cache_cleanup');
```

#### Filters

[](#filters)

```
// Modify translation before processing
$content = apply_filters('nm_pre_translate', $content, $from_lang, $to_lang);

// Modify translated content
$translated = apply_filters('nm_post_translate', $translated_content, $original_content);

// Customize language switcher output
$switcher_html = apply_filters('nm_language_switcher_html', $html, $args);

// Modify cache key generation
$cache_key = apply_filters('nm_cache_key', $cache_key, $content, $lang_from, $lang_to);
```

### Custom Functions

[](#custom-functions)

#### Translation Quality Check

[](#translation-quality-check)

```
$quality = nm_check_translation_quality($original, $translated);
echo "Quality Score: " . $quality['quality_score'] . "%";
```

#### Browser Language Detection

[](#browser-language-detection)

```
$browser_lang = nm_get_browser_language();
if ($browser_lang !== 'en') {
    // Redirect to appropriate language site
    nm_auto_redirect_language();
}
```

#### Custom Flag Emojis

[](#custom-flag-emojis)

```
$flag = nm_get_flag_emoji('de'); // Returns 🇩🇪
```

🧪 Testing
---------

[](#-testing)

### Test Suite

[](#test-suite)

Run the comprehensive test suite:

```
// Access via browser
http://yoursite.com/wp-content/plugins/nativelang-wordpress/test_cache.php

// Or include in code
include 'test_cache.php';
$test = new NativeMindTest();
$test->run_all_tests();
```

### Manual Testing Checklist

[](#manual-testing-checklist)

- Plugin activation without errors
- Polylang integration working
- Language switcher displays correctly
- Menu translations functional
- Cache operations working
- Admin dashboard accessible
- Multisite domain mapping (if applicable)

📊 Performance &amp; Optimization
--------------------------------

[](#-performance--optimization)

### Caching Strategy

[](#caching-strategy)

- **File-based caching** with automatic expiration (7 days default)
- **Memory caching** for repeated translations within single request
- **Intelligent cache keys** incorporating blog ID, network ID, and content hash
- **Automatic cleanup** via WordPress cron jobs

### Performance Tips

[](#performance-tips)

1. **API Key Management:** Use environment variables for API keys
2. **Cache Tuning:** Adjust cache expiration based on content update frequency
3. **Selective Translation:** Don't translate administrative content
4. **CDN Integration:** Serve static assets via CDN for better performance

🛡️ Security Considerations
--------------------------

[](#️-security-considerations)

### Data Protection

[](#data-protection)

- All user input is properly sanitized and validated
- Cache files are protected with .htaccess rules
- API keys should be stored securely (not in version control)
- CSRF protection on all admin actions

### Best Practices

[](#best-practices)

- Regular cache cleanup to prevent disk space issues
- Monitor API usage to avoid quota limits
- Use HTTPS for all translation API calls
- Implement proper error handling and logging

🐛 Troubleshooting
-----------------

[](#-troubleshooting)

### Common Issues

[](#common-issues)

#### "Polylang not found" Error

[](#polylang-not-found-error)

**Solution:** Install and activate Polylang plugin first.

#### Translations Not Appearing

[](#translations-not-appearing)

**Possible Causes:**

- Invalid Google Translate API key
- Network connectivity issues
- Cache directory permissions
- Polylang configuration incomplete

**Debug Steps:**

1. Check API key validity
2. Verify cache directory is writable
3. Enable WordPress debug logging
4. Run test suite for diagnostics

#### Language Switcher Not Displaying

[](#language-switcher-not-displaying)

**Possible Causes:**

- Theme conflicts
- CSS styling issues
- Polylang languages not configured

**Solutions:**

1. Check browser console for errors
2. Verify Polylang language setup
3. Add custom CSS if needed
4. Test with default theme

### Debug Mode

[](#debug-mode)

Enable debug mode for detailed logging:

```
// In wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

// Check logs at /wp-content/debug.log
```

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see our [GitHub repository](https://github.com/taxlien-online/nativelang-wordpress) for:

- Issue reporting
- Feature requests
- Pull request guidelines
- Development setup instructions

📄 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- **Polylang Team** for the excellent multilingual foundation
- **Google Translate** for reliable translation services
- **WordPress Community** for the robust platform
- **Contributors** who help improve this plugin

📞 Support
---------

[](#-support)

- **Documentation:** [nativemind.net](https://nativemind.net)
- **Email Support:**
- **Community Forum:** [WordPress.org Plugin Forum](https://wordpress.org/support/plugin/nativelang)
- **Professional Support:** Available for enterprise implementations

---

**Made with ❤️ by [NativeMind.net](https://nativemind.net) | Part of the [TaxLien.online](https://taxlien.online) project**

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4cdaf11bda32d8493fd30cb229f9bb971778e4a5f377529828299f4f10a745b?d=identicon)[dodonov](/maintainers/dodonov)

---

Top Contributors

[![Anton-Dodonov](https://avatars.githubusercontent.com/u/7759385?v=4)](https://github.com/Anton-Dodonov "Anton-Dodonov (11 commits)")

---

Tags

languagetranslationwordpresswordpressi18nl10ntranslationmultilingualcachemultisitepolylanggoogle-translate

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nativemind-wp-translation/health.svg)

```
[![Health](https://phpackages.com/badges/nativemind-wp-translation/health.svg)](https://phpackages.com/packages/nativemind-wp-translation)
```

###  Alternatives

[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[omaralalwi/lexi-translate

Laravel translation package with morph relationships and caching.

754.3k2](/packages/omaralalwi-lexi-translate)[markjaquith/wp-tlc-transients

A WP transients interface with support for soft-expiration, background updating of the transients.

34175.3k3](/packages/markjaquith-wp-tlc-transients)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23517.0k1](/packages/rtcamp-nginx-helper)[exploreimpact/contao-i18nl10n

The simplest way to create and manage multi-language sites with Contao.

201.4k](/packages/exploreimpact-contao-i18nl10n)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
