kynetcode/wpzylos-i18n

Internationalization wrapper for WPZylos framework

Maintainers

Package info

github.com/KYNetCode/wpzylos-i18n

Documentation

pkg:composer/kynetcode/wpzylos-i18n

Fund package maintenance!

Paypal

Statistics

Installs: 15

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-16 18:52 UTC

This package is auto-updated.

Last update: 2026-06-16 20:01:15 UTC


README

PHP Version License GitHub

Internationalization wrapper for WPZylos framework.

📖 Full Documentation | 🐛 Report Issues

Features

  • Translation - Plugin-scoped translate(), echo(), sprintf() methods
  • Pluralization - Handle singular/plural forms with plural()
  • Context Support - Disambiguate translations with translateWithContext()
  • Escaped Output - Safe HTML/attribute output with esc() and escAttr()
  • Auto Loading - Automatic text domain loading via service provider

Requirements

Requirement Version
PHP ^8.0
WordPress 6.0+

Installation

composer require KYNetCode/wpzylos-i18n

Quick Start

use WPZylos\Framework\I18n\Translator;

$translator = new Translator($context);

// Translate strings
$label = $translator->translate('Hello World');

// Echo with HTML escaping
$translator->echo('Save Changes');

// Pluralization
$message = $translator->plural(
    'You have %d item',
    'You have %d items',
    $count
);

// Formatted translation
$greeting = $translator->sprintf('Hello, %s!', $userName);

Core Features

Translation Methods

// Simple translation
$label = $translator->translate('Settings');

// Echo (outputs esc_html-escaped translation)
$translator->echo('Save Changes');

// With sprintf formatting
$msg = $translator->sprintf('Welcome, %s!', $name);

// Pluralization
$text = $translator->plural(
    'You have %d item',
    'You have %d items',
    $count
);

// Contextual translation
$post = $translator->translateWithContext('Post', 'noun');

Escaped Output

// HTML-safe translation
$safe = $translator->esc('Settings');

// Attribute-safe translation
$attr = $translator->escAttr('Click here');

Text Domain

// Get the plugin's text domain
$domain = $translator->textDomain();

Translation Loading

use WPZylos\Framework\I18n\I18n;

// Instance usage
$i18n = new I18n($context);
$i18n->load();
$i18n->isLoaded(); // true

// Static convenience
I18n::loadFor($context);

// Get MO file path
$path = $i18n->getMoFilePath('de_DE');
// -> {plugin}/resources/lang/{domain}-de_DE.mo

Related Packages

Package Description
wpzylos-core Application foundation
wpzylos-scaffold Plugin template

Documentation

For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.

Support the Project

License

MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Made with love by KYNetCode