Assistant i18n WordPress

VérifiéSûr

Gérez l'internationalisation WordPress en utilisant les bonnes fonctions de traduction et en générant des fichiers POT pour vos plugins.

Spar Skills Guide Bot
DeveloppementDébutant
2002/06/2026
Claude CodeCursorWindsurfCopilot
#wordpress#internationalization#i18n#translation#localization

Recommandé pour

Notre avis

Ce skill facilite la gestion de l'internationalisation d'un plugin WordPress en fournissant les bonnes fonctions de traduction et la génération de fichier POT pour le domaine de texte 'retrologin'.

Points forts

  • Guide clair sur l'utilisation des fonctions de traduction WordPress avec échappement
  • Inclut la génération de fichier POT via Composer
  • Couvre les cas d'usage courants (variables PHP, sortie directe, attributs HTML)
  • Rappelle l'importance du domaine de texte et des bonnes pratiques

Limites

  • Spécifique au domaine 'retrologin' uniquement
  • Ne couvre pas les formes plurielles (ngettext)
  • Pas de gestion des fichiers de traduction existants (.po/.mo)
Quand l'utiliser

Utilisez ce skill lorsque vous devez ajouter des chaînes traduisibles dans un plugin WordPress avec le domaine 'retrologin'.

Quand l'éviter

Ne l'utilisez pas pour des projets non WordPress ou pour des plugins ayant un domaine de texte différent.

Analyse de sécurité

Sûr
Score qualité90/100

The skill provides guidance on WordPress internationalization functions and a legitimate 'composer run make-pot' command. No destructive or exfiltrating actions are present.

Aucun point d'attention détecté

Exemples

Add a translatable string for a button
Add a translatable string for a login button using the correct WordPress i18n function with escaping and the 'retrologin' text domain.
Generate POT file
Generate the POT file for the retrologin plugin using Composer.
Escape translated attribute
How do I safely translate and escape a placeholder attribute in WordPress for the retrologin plugin?

name: i18n-helper description: Handle WordPress internationalization. Use when adding translatable strings.

i18n Helper

Instructions

When adding translatable strings to the plugin:

  1. Use the correct text domain: 'retrologin'
  2. Choose the right function:
    • __() - Return translated string
    • _e() - Echo translated string
    • esc_html__() - Return escaped translated string
    • esc_html_e() - Echo escaped translated string
    • esc_attr__() - Return escaped for HTML attributes
  3. Generate POT file: composer run make-pot
  4. Keep strings in English (US)

Translation Functions

| Function | Output | Use When | | ---------------------------- | --------------- | ----------------------------- | | __($text, $domain) | Return | Strings in PHP variables | | _e($text, $domain) | Echo | Direct output | | esc_html__($text, $domain) | Return + escape | Displaying user content | | esc_html_e($text, $domain) | Echo + escape | Direct output of user content | | esc_attr__($text, $domain) | Return + escape | HTML attributes |

Example

// Basic usage
__('Login Page', 'retrologin');
_e('Welcome back!', 'retrologin');

// With escaping
esc_html__('Please log in to continue', 'retrologin');
esc_attr__('Username', 'retrologin');

// In attributes
<input placeholder="<?php esc_attr_e('Enter username', 'retrologin'); ?>">

Generate Translations

# Generate POT file for translations
composer run make-pot

# POT file location: inc/languages/retrologin.pot

Guidelines

  • Always include text domain second parameter
  • Use escaping functions for user-generated content
  • Keep strings concise for translation
  • Avoid embedding variables in translatable strings
Skills similaires