# 🌍 Internationalization (i18n) / 国际化支持

**Version**: v1.0.0
**Last Updated**: 2026-03-24

---

## 📖 Overview / 概述

Trading Assistant supports both English and Chinese languages.
交易助手支持英文和中文两种语言。

- **Default Language**: English (`en`)
- **Supported Languages**: English (`en`), Chinese Simplified (`zh_CN`)
- **Configuration**: Set via environment variable or config file

---

## ⚙️ Configuration / 配置

### Method 1: Environment Variable / 方式 1：环境变量

```bash
# English (Default)
export TRADING_ASSISTANT_LANG=en

# Chinese Simplified
export TRADING_ASSISTANT_LANG=zh_CN
```

### Method 2: Config File / 方式 2：配置文件

Create `config.json`:
```json
{
  "language": "zh_CN",
  "risk_profile": "moderate",
  "watchlist": ["NVDA", "AAPL", "SPY"]
}
```

### Method 3: Code / 方式 3：代码中设置

```python
from config import set_language

set_language("zh_CN")  # or "en"
```

---

## 📁 Language Files / 语言文件

```
trading-assistant/
├── locales/
│   ├── en.json          # English translations
│   └── zh_CN.json       # Chinese translations
├── config.py            # Language configuration
└── i18n.py             # Internationalization utilities
```

---

## 📝 Example Output / 输出示例

### English (Default)
```
📊 NVDA Support/Resistance Analysis
💰 Current Price: $175.64

🔴 Resistance Levels:
  1. $177.26 (+0.9%) [weak]
  2. $180.00 (+2.5%) [weak]

🟢 Support Levels:
  1. $175.00 (-0.4%) [weak]
  2. $171.72 (-2.2%) [medium]
```

### Chinese (中文)
```
📊 NVDA 支撑/阻力位分析
💰 当前价格：$175.64

🔴 阻力位:
  1. $177.26 (+0.9%) [weak]
  2. $180.00 (+2.5%) [weak]

🟢 支撑位:
  1. $175.00 (-0.4%) [weak]
  2. $171.72 (-2.2%) [medium]
```

---

## 🔧 Adding New Languages / 添加新语言

1. Create new file in `locales/` directory
2. Translate all strings
3. Add language code to `i18n.py`

Example `locales/ja.json`:
```json
{
  "support_resistance": "サポート/レジスタンス分析",
  "current_price": "現在価格"
}
```

---

## 📚 Translation Keys / 翻译键

| Key | English | Chinese (简体) |
|-----|---------|----------------|
| `support_resistance` | Support/Resistance | 支撑/阻力位 |
| `current_price` | Current Price | 当前价格 |
| `resistance_levels` | Resistance Levels | 阻力位 |
| `support_levels` | Support Levels | 支撑位 |
| `trading_signal` | Trading Signal | 交易信号 |
| `recommendation` | Recommendation | 建议 |
| `confidence` | Confidence | 置信度 |
| `position_size` | Position Size | 仓位大小 |
| `risk_amount` | Risk Amount | 风险金额 |
| `stop_loss` | Stop Loss | 止损 |

---

## ✅ Best Practices / 最佳实践

1. **Use translation keys** - Never hardcode strings
2. **Default to English** - Fallback if translation missing
3. **Test both languages** - Verify output in both `en` and `zh_CN`
4. **Keep translations updated** - Update all languages when adding new features

---

## 🐛 Troubleshooting / 故障排除

### Issue: Output still in English after setting Chinese
**Solution**: Check environment variable is set correctly
```bash
echo $TRADING_ASSISTANT_LANG  # Should output: zh_CN
```

### Issue: Some strings not translated
**Solution**: Add missing keys to `locales/zh_CN.json`

---

**Made with ❤️ for global users**
