# Translation Files

This directory contains translation files for the Headline Ligatures & Styles plugin.

## Available Translations

- **French (France) - fr_FR** ✓ Complete (171 strings)
- **Spanish (Spain) - es_ES** ✓ Complete (171 strings)
- More translations welcome!

## For Translators

### Getting Started

1. **POT File**: The `headline-ligatures-styles.pot` file is the template containing all translatable strings
2. **Create Your Translation**: Use a tool like [Poedit](https://poedit.net/) to create a `.po` file for your language
3. **Language Codes**: Use WordPress language codes (e.g., `es_ES` for Spanish (Spain), `fr_FR` for French, `de_DE` for German)

### Translation Process

1. Open `headline-ligatures-styles.pot` in Poedit or another gettext editor
2. Create a new translation from the POT file
3. Translate the strings
4. Save the file as `headline-ligatures-styles-{locale}.po` (e.g., `headline-ligatures-styles-es_ES.po`)
5. The editor will automatically generate the compiled `.mo` file

### File Naming Convention

- **PO files**: `headline-ligatures-styles-{locale}.po`
- **MO files**: `headline-ligatures-styles-{locale}.mo`
- **JS JSON files**: `headline-ligatures-styles-{locale}-{hash}.json` (automatically generated by WordPress)

### JavaScript Translations

This plugin includes JavaScript strings that need translation. WordPress will automatically:
1. Look for the `.po`/`.mo` files
2. Generate JSON translation files for JavaScript when needed
3. Load them in the block editor

You only need to translate the PO file - WordPress handles the rest!

## For Developers

### Regenerating the POT File

To regenerate the POT file after adding new translatable strings:

```bash
php scripts/generate-pot.php
```

Or if you have WP-CLI installed:

```bash
wp i18n make-pot . languages/headline-ligatures-styles.pot --domain=headline-ligatures-styles
```

### Compiling PO to MO Files

After editing a `.po` file, compile it to `.mo` format:

```bash
# Compile specific locale
php scripts/compile-po.php es_ES

# Or compile all PO files
php scripts/compile-po.php
```

### Adding Translatable Strings

- **PHP**: Use `__()`, `_e()`, `_n()`, `_x()`, `esc_html__()`, `esc_html_e()`, etc.
- **JavaScript**: Use `wp.i18n.__()`, `wp.i18n._n()`, `wp.i18n._x()`, etc.
- **Text Domain**: Always use `headline-ligatures-styles`

### Testing Translations

1. Install the `.po` and `.mo` files in this directory
2. Change your WordPress language in Settings → General
3. Clear all caches
4. Visit the block editor to test JavaScript translations

## Resources

- [WordPress I18n Documentation](https://developer.wordpress.org/apis/internationalization/)
- [Poedit](https://poedit.net/) - Translation editor
- [GlotPress](https://translate.wordpress.org/) - WordPress.org translation platform
- [Language Codes](https://make.wordpress.org/polyglots/teams/)
