承接 kynetcode/wpzylos-i18n 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kynetcode/wpzylos-i18n

Composer 安装命令:

composer require kynetcode/wpzylos-i18n

包简介

Internationalization wrapper for WPZylos framework

README 文档

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

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固