Daniyal Dev — Dev Project

01What GTranslate Pro Actually Does

Put simply: it reads your site’s HTML, pulls out the text, sends it through a translation engine, rebuilds the page in the target language, and stores that output in a cache. The next visitor who wants the same language gets the page instantly, with zero API calls.

It supports over 100 languages. You can use a free built-in provider with no API key, or connect your own Google Cloud Translation API key for enterprise-level reliability. Both options work with the same caching system.

It’s built for WordPress developers and site owners who want multilingual support without turning their site into a slow mess.

Who is this for?
If you run a blog, WooCommerce store, portfolio, or business site and want to reach visitors in their own language, this plugin handles it from the WordPress dashboard. No complicated config, no external services to wire up manually.

02The Caching System: Where the Real Value Is

Translation is slow by nature. Every API call takes time. If your page has 80 text segments and you’re calling the API for each page load, that adds up fast.

GTranslate Pro’s caching layer solves this completely. Here’s what happens from the moment someone visits a translated page:

Cache Request Flow
Visitor Request
Cache Check
Hit or Miss?
✅ Cache Hit: Serve immediately (<50ms)
⚡ Cache Miss: Translate → Cache → Serve
Click either path above to see what happens.

After the first visit, every repeat request gets the cached version. For busy sites, this means your translation API is barely touched after the initial warmup.

Database Cache vs. Filesystem Cache

You can choose where translations are stored. Both work, but they have different strengths:

Feature Database Cache Filesystem Cache
Setup Automatic Writable directory needed
Speed Fast Faster (file I/O)
WordPress Backup Yes Separate backup needed
High Traffic Good Better
Auto Cleanup Daily WP-Cron Daily WP-Cron
Recommendation
Start with Database Cache. If your site gets a lot of traffic and translation pages start feeling heavy, switch to Filesystem. For most sites, Database handles it perfectly.

03Everything You Get Out of the Box

Here’s a quick overview of what’s included, from the basics to the more advanced stuff:

🌐

100+ Languages

All major world languages with flag icons, native names, and regional variants like zh-cn and pt-br.

Smart Caching

Database or filesystem storage, configurable expiry (1-365 days), auto-cleanup, and real-time hit/miss stats.

🔀

Dual Providers

Free built-in provider (no key needed) or official Google Cloud API for enterprise-grade reliability.

🛡️

Rate Limiting

Built-in throttle: configurable requests per minute plus a circuit breaker that stops cascading API failures.

🔍

SEO Ready

Automatic hreflang tags and HTML lang attributes so search engines understand your language variants.

📊

Admin Dashboard

Cache stats, translation logs, settings import/export, and a one-click “Clear Cache” button.

🚫

Content Exclusions

Skip specific pages by URL, or exclude page elements by CSS selector. Useful for keeping prices or code snippets untranslated.

🔧

WordPress Hooks

Full filter and action support so developers can extend or override any part of the translation pipeline.

04Getting It Running: Installation

Installation is straightforward. You’ll need WordPress 5.8+ and PHP 7.4+ on your server.

Download and Extract the Plugin

Download the zip file and extract it to wp-content/plugins/GTranslate.

Install Composer Dependencies

Open your terminal and run the commands below from inside the plugin folder.

Activate in WordPress

Go to Dashboard → Plugins, find “GTranslate Pro”, and click Activate. The plugin will create its database table and set up scheduled cleanup automatically.

Open the Plugin Settings

Navigate to Dashboard → GTranslate and start your configuration. Takes about 3 minutes from here.

Bash
# Navigate to the plugin folder
cd wp-content/plugins/GTranslate

# Install dependencies
composer install
What Activating Does
On activation, the plugin creates the wp_gtranslate_cache table, writes default settings to the WordPress options table, and schedules a daily WP-Cron job to clean up expired cache entries.

05Configuring Your First Translation

Once activated, go to Dashboard → GTranslate. You’ll see five tabs: General, Languages, Translation, Display, and Advanced.

Step 1: Pick Your Translation Provider

Under the General tab, choose your provider:

  • Free Built-in Provider: Works with no API key. Good for most blogs and small business sites.
  • Official Google Cloud API: Requires an API key from Google Cloud Console. Better quality and more reliable for high-traffic sites. Billing must be enabled on your Cloud project.
Settings General Tab
PHP · Change provider programmatically
// Switch provider via WordPress action
do_action('gtranslate_switch_provider', 'official');

// Or using the plugin instance
$plugin = \GTranslate\Plugin::instance();
$plugin->switch_provider('official');

Step 2: Set Your Source Language and Target Languages

Your source language is the language your site is written in (almost always English). Target languages are everything else you want to offer.

The Languages tab has a searchable multi-select with all 100+ options. You can hit “Select All” to enable everything, or pick specific languages for your audience.

Languages List Settings Page

Step 3: Choose Which HTML Tags to Translate

Under the Translation tab, you control which HTML elements get processed. The default set covers most cases:

Default Tags
p, h1, h2, h3, h4, h5, h6, span, button, a, li, td, th, label

If your site has simple content, you might only need p, h1h6, and li. Removing tags you don’t need reduces the amount of work the plugin does per page.

Performance Tip
The fewer tags you translate, the faster the plugin processes each page. Only add tags you actually need translated.

06Adding the Language Switcher to Your Site

Visitors need a way to switch languages. GTranslate Pro gives you five placement options, and you only need one.





[gtranslate_switcher]
Paste into any page, post, or text widget content.

Shortcode attributes let you override the global style per placement:

Shortcode
<!-- Default dropdown -->
[gtranslate_switcher]

<!-- Button group, no flags -->
[gtranslate_switcher style="buttons" show_flags="0"]

<!-- Flags only, no names -->
[gtranslate_switcher show_names="0" show_flags="1"]

Go to Appearance → Widgets, find “GTranslate Language Switcher”, and drag it into any widget area (sidebar, footer, etc.). Each widget instance has its own title, style, and display options.

In GTranslate → Display → Switcher Position, select “Menu”. The plugin automatically appends the language switcher to your primary navigation menu. No shortcode or widget needed.

Set the position to Header or Footer in the Display settings. The plugin hooks into wp_head or wp_footer respectively and injects the switcher automatically on every page.

PHP · Template Code
$switcher = new \GTranslate\Language_Switcher(
    \GTranslate\Plugin::instance()->get_settings()
);

echo $switcher->render([
    'style'      => 'default',
    'show_flags' => true,
    'show_names' => true,
]);

What the Switcher Looks Like

Dropdown Style
🇺🇸 English
Button Style
🇺🇸 English
🇪🇸 Spanish
🇫🇷 French
🇩🇪 German
🇯🇵 Japanese
🇸🇦 Arabic
Click a button to preview selection

Customizing the Switcher’s Look

The Display settings tab has a Custom CSS field. The switcher uses predictable class names so it’s easy to style:

CSS
/* Main container */
.gtranslate_widget {
    background: #1e293b;
    border-radius: 10px;
    padding: 8px;
}

/* Active / selected language */
.current-language {
    font-weight: 600;
    color: #6366f1;
}

/* Language option hover */
.language-option:hover {
    background: rgba(99, 102, 241, 0.1);
}

07Built-in API Protection: Rate Limits and the Circuit Breaker

If something goes wrong with your translation API, a naive plugin would keep hammering it indefinitely. That can get expensive fast, or get your key suspended.

GTranslate Pro has two layers of protection built in.

Rate Limiting

The default is 100 requests per minute. Once that limit is hit, the plugin queues requests and processes them in the next window. If the queue is full, extra requests are dropped gracefully. You can tune this from Advanced Settings → Requests per Minute.

The Circuit Breaker

This is the smarter protection. After 3 consecutive API failures, the circuit “opens” and stops sending requests for 60 seconds. After that timeout, it sends a test request. If it succeeds, normal operation resumes. If not, the circuit stays open longer.

CLOSED

Normal operation. API calls go through as usual.

OPEN

3 failures hit. All requests blocked for 60 seconds.

HALF-OPEN

Timeout passed. One test request sent to check recovery.

Why This Matters
Without the circuit breaker, a temporary API outage could create hundreds of failed requests in seconds. With it, your site quietly waits, then recovers automatically when the service is back up.

08Excluding Pages and Elements You Don’t Want Translated

Not every page needs translation. Privacy policies, checkout flows, or pages with code examples are good candidates to exclude.

Exclude Pages by URL Pattern

Under Translation settings, add URL patterns one per line:

URL Exclusion Patterns
/privacy/
/terms/
/checkout/
/account/

Exclude Elements by CSS Selector

If a specific section of a page shouldn’t be translated, add its CSS selector:

CSS Selector Exclusions
.no-translate
#code-examples
.product-sku
.widget-title

Or Use the HTML Attribute Directly

HTML
<!-- This block won't be touched by the plugin -->
<div class="no-translate">
    SKU: ABC-1234
</div>

<!-- Or use a data attribute -->
<p data-translate="false">Preserved content</p>

Excluding from Code (via WordPress Filter)

PHP
add_filter('gtranslate_should_exclude_page', function($exclude, $uri) {
    // Exclude all URLs under /members/
    if (strpos($uri, '/members/') !== false) {
        return true;
    }
    return $exclude;
}, 10, 2);

09For Developers: Hooks and Custom Providers

GTranslate Pro is built around WordPress hooks, so you can tap into the pipeline at any point without editing plugin files.

Useful Filters at a Glance

PHP · Hooks Reference
// Modify which languages are available to visitors
add_filter('gtranslate_target_languages', function($langs) {
    return ['es', 'fr', 'de']; // limit to 3
});

// Modify translated content before it's sent to the browser
add_filter('gtranslate_translate_content', function($translated, $original, $lang) {
    return $translated; // post-process here
}, 10, 3);

// Do something after the user switches language
add_action('gtranslate_language_switched', function($new, $old) {
    // Log, track, or redirect
}, 10, 2);

// Run code after cache is cleared
add_action('gtranslate_cache_cleared', function($language) {
    // Purge your CDN, for example
});

Clear Cache for One Language

PHP
$cache = \GTranslate\Plugin::instance()->get_cache();

// Clear all cached translations
$cache->clear_all();

// Clear only Spanish translations
$cache->clear_by_language('es');

10Common Issues and How to Fix Them

Most problems have simple causes. Here are the ones that come up most often:

🔇
Content isn’t being translated at all

Check three things: first, confirm the plugin is active under Plugins. Second, go to GTranslate → Translation and check your Tags to Translate list. If the tag your content uses (like div) isn’t in the list, it won’t be processed. Third, turn on Logging under Advanced and reload the page, then check the activity log for any error messages.

🐢
Translated pages are slow

This almost always means caching isn’t working. Go to Advanced and confirm that Cache is enabled. If it is, check your cache hit rate under GTranslate → Status. A hit rate below 70% means something is preventing cache reuse. Try clicking “Clear Cache” and visiting a translated page twice: the second visit should be faster than the first. If your site is high-traffic, switch to Filesystem cache and bump the batch size to 100-200.

🔑
“API key not configured” error with Official API

Go to General settings and paste your key again, making sure there are no leading or trailing spaces. Then click “Test API Key” which runs a live validation. If it fails, log into Google Cloud Console, confirm the Cloud Translation API is enabled on your project, and verify that billing is active. Keys without billing enabled will be rejected even if the key itself is valid.


Translations stopped after a few errors

This is the circuit breaker doing its job. It opens after 3 consecutive failures and stays open for 60 seconds. Wait a minute, then reload the page. If translations are still failing, look at the activity log to find what the original error was. Usually it’s a network timeout or API key issue. Once you fix the root cause, the circuit resets automatically.

📉
Site gets slower over time

The cache table is growing and WP-Cron isn’t cleaning it up. This usually happens when WP-Cron is disabled on your server. You can either enable server-side cron, or manually clear the cache from the dashboard. Switching to Filesystem cache also reduces database load significantly for sites with large translation volumes.

11Download

Ready to Go Multilingual?

Download GTranslate Pro, install it in minutes, and have your first translated page cached and serving visitors fast today.

Google Translate Pro v1.0.0 • 600.57 KB
20
How did this post feel?

Share this with your dev circle

Found this useful? Boost another developer by sharing it forward.

Link copied to clipboard