Lang Forge is designed for performance with built-in caching at multiple levels.
In-Memory Translation Cache
php
// First call: 1 DB query (fetches entire translation group)
$translations = langforge_get_post_translations(42);
// Second call for any post in the same group: 0 DB queries
$translations = langforge_get_post_translations(99); // post #99 is in same group as #42String Translation Preloading
php
// First __() call for English: 1 DB query loads ALL English strings
echo __('Hello', 'theme');
// All subsequent calls: 0 DB queries
echo __('Goodbye', 'theme');
echo __('Contact', 'theme');
// ... (zero additional queries no matter how many strings)Measuring
The number of queries Lang Forge adds to a page depends on the page and the site. The Query Monitor plugin lists the queries by plugin, so you can count them on your own site.
Performance Tips
- Use a persistent object cache. Redis or Memcached reduces database load.
- Preload translations in custom loops. Call
langforge_get_post_translations()before entering your display loop.
- Use auto-registration. Add your theme’s text domain to the auto-registration settings. Standard
__()with auto-registration handles string detection automatically.
- Minimize secondary queries. Let Lang Forge handle the main query filtering.
- Use page caching. Full-page caching eliminates nearly all performance overhead.
- Optimize the postmeta table. For sites with more than 50,000 posts:
sql
ALTER TABLE wp_postmeta ADD INDEX idx_lf_language (meta_key(20), meta_value(10));—