# Translation Files Installation Guide

## Files Included

You now have translation files for 4 languages:

1. **Spanish** (es_ES) - `ezycreate-for-woocommerce-es_ES.po`
2. **Japanese** (ja) - `ezycreate-for-woocommerce-ja.po`
3. **Chinese Simplified** (zh_CN) - `ezycreate-for-woocommerce-zh_CN.po`
4. **Arabic** (ar) - `ezycreate-for-woocommerce-ar.po`

## Step 1: Compile PO Files to MO Files

.PO files are source files (human-readable)
.MO files are compiled files (machine-readable - required by WordPress)

### Option A: Using Poedit (Easiest - Recommended)

1. **Download Poedit**: https://poedit.net/
2. **Open each .po file** in Poedit
3. **Save** (File → Save or Ctrl+S)
4. Poedit **automatically creates the .mo file**
5. Done!

### Option B: Using msgfmt (Command Line)

```bash
# For Spanish
msgfmt -o ezycreate-for-woocommerce-es_ES.mo ezycreate-for-woocommerce-es_ES.po

# For Japanese
msgfmt -o ezycreate-for-woocommerce-ja.mo ezycreate-for-woocommerce-ja.po

# For Chinese
msgfmt -o ezycreate-for-woocommerce-zh_CN.mo ezycreate-for-woocommerce-zh_CN.po

# For Arabic
msgfmt -o ezycreate-for-woocommerce-ar.mo ezycreate-for-woocommerce-ar.po
```

### Option C: Using Loco Translate Plugin (In WordPress)

1. Install "Loco Translate" plugin in WordPress
2. Go to Loco Translate → Plugins → Ezycreate for WooCommerce
3. Upload the .po files
4. Plugin automatically compiles to .mo

## Step 2: Upload Files to Plugin

Upload ALL files (both .po and .mo) to the `languages/` folder:

```
ezycreate/
└── languages/
    ├── ezycreate-for-woocommerce-es_ES.po
    ├── ezycreate-for-woocommerce-es_ES.mo
    ├── ezycreate-for-woocommerce-ja.po
    ├── ezycreate-for-woocommerce-ja.mo
    ├── ezycreate-for-woocommerce-zh_CN.po
    ├── ezycreate-for-woocommerce-zh_CN.mo
    ├── ezycreate-for-woocommerce-ar.po
    └── ezycreate-for-woocommerce-ar.mo
```

## Step 3: Test Translations

### Test Japanese Translation:

1. **Go to WordPress Admin** → Settings → General
2. **Change "Site Language"** to "日本語" (Japanese)
3. **Visit plugin pages**:
   - Menu should show: "Ezycreate商品"
   - Settings should show: "設定"
   - Button should show: "カスタマイズ"

### Test Chinese Translation:

1. Change "Site Language" to "简体中文" (Chinese Simplified)
2. Check plugin pages:
   - Menu: "Ezycreate产品"
   - Settings: "设置"
   - Button: "定制"

### Test Arabic Translation:

1. Change "Site Language" to "العربية" (Arabic)
2. Check plugin pages:
   - Menu: "منتجات Ezycreate"
   - Settings: "الإعدادات"
   - Button: "تخصيص"
3. **Note**: Page should flip to RTL (Right-to-Left)

## Step 4: Test RTL Support (Arabic)

Arabic uses Right-to-Left layout. Test that your plugin looks good:

### Create RTL CSS (if needed):

Create `assets/css/admin-rtl.css`:
```css
/* WordPress automatically loads this for RTL languages */
.ezy-settings-form {
    direction: rtl;
    text-align: right;
}

.ezy-settings-form label {
    text-align: right;
}

.ezy-settings-form input[type="text"],
.ezy-settings-form input[type="password"] {
    text-align: right;
}
```

## Verification Checklist

After uploading:

- [ ] Both .po and .mo files are in `languages/` folder
- [ ] Files are named correctly with language codes
- [ ] WordPress can switch to each language
- [ ] Plugin text appears in correct language
- [ ] No English text showing (all translated)
- [ ] Buttons and links work properly
- [ ] Arabic shows RTL layout correctly

## Language Codes Reference

| Language | WordPress Code | File Name |
|----------|----------------|-----------|
| Spanish (Spain) | es_ES | `ezycreate-for-woocommerce-es_ES.po/mo` |
| Japanese | ja | `ezycreate-for-woocommerce-ja.po/mo` |
| Chinese (Simplified) | zh_CN | `ezycreate-for-woocommerce-zh_CN.po/mo` |
| Arabic | ar | `ezycreate-for-woocommerce-ar.po/mo` |

## For WordPress.org Submission

Include ALL translation files in your submission:

1. ✅ All .po files (source files)
2. ✅ All .mo files (compiled files)
3. ✅ The .pot template file

WordPress.org will:
- Display available languages on plugin page
- Allow community to improve translations
- Auto-distribute to users

## Troubleshooting

### Translations Not Showing?

**Check 1**: Are .mo files present?
```bash
ls languages/
# Should see both .po and .mo for each language
```

**Check 2**: Correct file naming?
```bash
# Format must be: plugintextdomain-languagecode.mo
# Example: ezycreate-for-woocommerce-ja.mo
```

**Check 3**: Clear cache
```bash
# In wp-config.php temporarily add:
define('WP_DEBUG', true);

# Check wp-content/debug.log for errors
```

**Check 4**: Regenerate .mo files
- Open .po in Poedit
- Save again (regenerates .mo)

### Arabic Not RTL?

Add this to your plugin CSS:
```css
body.rtl .ezycreate-admin-page {
    direction: rtl;
}
```

### Characters Showing as �?

File encoding issue. Open in Poedit and re-save:
- File → Preferences → Editor
- Ensure "UTF-8" encoding

## Quick Compilation Script

Save as `compile-translations.sh`:

```bash
#!/bin/bash
echo "Compiling translation files..."

for po_file in languages/*.po; do
    mo_file="${po_file%.po}.mo"
    echo "Compiling $po_file → $mo_file"
    msgfmt -o "$mo_file" "$po_file"
done

echo "✅ All translations compiled!"
```

Make executable and run:
```bash
chmod +x compile-translations.sh
./compile-translations.sh
```

## Summary

**Easiest Method:**
1. Open each .po file in Poedit
2. Save (creates .mo automatically)
3. Upload both files to `languages/` folder
4. Change WordPress language to test
5. Done! ✅

**For WordPress.org:**
Just include all files - WordPress.org handles distribution!

## Support

If you need help:
- Poedit: https://poedit.net/support
- WordPress i18n: https://developer.wordpress.org/plugins/internationalization/
- WordPress Support: https://wordpress.org/support/
