Skip to content

Commit

Permalink
docs: update README with custom language styles
Browse files Browse the repository at this point in the history
  • Loading branch information
kargnas committed Jul 23, 2024
1 parent 287a5a9 commit a3d7937
Showing 1 changed file with 97 additions and 4 deletions.
101 changes: 97 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

AI-powered translation tool for Laravel language files

## 💡 New Feature: Custom Language Styles

We've expanded our capabilities with support for custom language styles, allowing for unique and creative translations.

### Built-in Styles
Our package already includes several built-in language styles, such as:

- `ko_kp`: North Korean style Korean
- Various regional dialects and language variants

These are automatically available and don't require additional configuration.

### Custom Style: Reddit English
As an example of custom styling, we've implemented a "Reddit style" English:

This style mimics the casual, often humorous language found on Reddit, featuring:
- Liberal use of sarcasm
- Internet slang and meme references
- Playful skepticism

Example config:
```php
'locale_names' => [
'en_reddit' => 'English (Reddit)',
],
'additional_rules' => [
'en_reddit' => [
"- Incorporate sarcasm and exaggeration",
"- Use popular internet slang and meme references",
"- Add humorous calls for sources on obvious statements",
// More Reddit-specific rules can be added
],
],
```

### Creating Your Own Custom Styles
You can create your own custom language styles by adding new entries to the `locale_names` and `additional_rules` in the configuration. This allows you to tailor translations to specific audiences or platforms.

These custom styles offer creative ways to customize your translations, adding a unique flair to your localized content. Use responsibly to enhance user engagement while maintaining clarity and appropriateness for your audience.

## Overview

Laravel AI Translator is a powerful tool designed to streamline the localization process in Laravel projects. It automates the tedious task of translating strings across multiple languages, leveraging advanced AI models to provide high-quality, context-aware translations.
Expand All @@ -25,9 +65,9 @@ Whether you're working on a personal project or a large-scale application, Larav
- Supports custom translation rules for enhanced quality and project-specific requirements
- Efficiently processes large language files, saving time and effort
- Respects Laravel's localization system, ensuring compatibility with your existing setup
- **NEW**: Chunking functionality for cost-effective translations: Processes multiple strings in a single AI request, significantly reducing API costs and improving efficiency
- **NEW**: String validation to ensure translation accuracy: Automatically checks and validates AI translations to catch and correct any errors or mistranslations
- **NEW**: Support for Laravel 11: Now compatible with the latest Laravel version for cutting-edge projects
- Chunking functionality for cost-effective translations: Processes multiple strings in a single AI request, significantly reducing API costs and improving efficiency
- String validation to ensure translation accuracy: Automatically checks and validates AI translations to catch and correct any errors or mistranslations
- Support for Laravel 11: Now compatible with the latest Laravel version for cutting-edge projects

Also, this tool is designed to translate your language files intelligently:

Expand All @@ -38,6 +78,43 @@ Also, this tool is designed to translate your language files intelligently:
- Tone Consistency: Maintains a consistent tone across translations, customizable via configuration.

Do you want to know how this works? See the prompt in `src/AI`.
## Custom Language Styles

In addition to standard language translations, this package now supports custom language styles, allowing for unique and creative localizations.

### Built-in Styles
The package includes several built-in language styles:
- `ko_kp`: North Korean style Korean
- Various regional dialects and language variants

These are automatically available and don't require additional configuration.

### Custom Style Example: Reddit English
As an demonstration of custom styling capabilities, we've implemented a "Reddit style" English:

This style mimics the casual, often humorous language found on Reddit, featuring:
- Liberal use of sarcasm
- Internet slang and meme references
- Playful skepticism

Example configuration:
```php
'locale_names' => [
'en_reddit' => 'English (Reddit)',
],
'additional_rules' => [
'en_reddit' => [
"- Incorporate sarcasm and exaggeration",
"- Use popular internet slang and meme references",
"- Add humorous calls for sources on obvious statements",
],
],
```

### Creating Custom Styles
You can create your own custom language styles by adding new entries to the `locale_names` and `additional_rules` in the configuration. This allows you to tailor translations to specific audiences or platforms.

These custom styles offer creative ways to customize your translations, adding a unique flair to your localized content. Use responsibly to enhance user engagement while maintaining clarity and appropriateness for your audience.

## Prerequisites

Expand Down Expand Up @@ -145,6 +222,22 @@ The package will generate translations like these:
'notifications.refresh_after_1_min' => 'รีเฟรชหลังจาก 1 นาที จะมีเนื้อหาใหม่ให้ดู! (โมเดลก่อนหน้า: :model, อัปเดตเมื่อ: :updated_at)',
);
```
- 🤣 Korean (North Korea):
```php
<?php
return array (
'notifications.new_feature_search_sentence' => '혁명적 새로운 기능: 동무들! 이제 단어뿐만 아니라 문장도 입력하여 단어의 력사를 확인할 수 있습니다. 모국어로도 괜찮습니다. 인공지능이 중국어로 번역해드리겠습니다.',
'notifications.refresh_after_1_min' => '1분후에 새로고침하십시요. 새로운 내용을 볼수 있습니다! (이전 모델: :model, 갱신: :updated_at)',
);
```
- 🤣 English (Reddit):
```php
<?php
return array (
'notifications.new_feature_search_sentence' => 'Whoa, hold onto your keyboards, nerds! We\'ve leveled up our search game. Now you can type entire sentences, not just measly words. Mind. Blown. And get this - it even works in your weird non-English languages! Our AI overlord will graciously translate your gibberish into Chinese. You\'re welcome.',
'notifications.refresh_after_1_min' => 'Yo, hit that F5 in 60 seconds, fam. Fresh content incoming! (Previous model was :model, last updated when dinosaurs roamed the Earth at :updated_at)',
);
```
## Configuration
Expand Down Expand Up @@ -182,7 +275,7 @@ This will create a `config/ai-translator.php` file where you can modify the foll
- `locale_names`: This mapping of locale codes to language names enhances translation quality by providing context to the AI.
- `additional_rules`: Add custom rules to the translation prompt. This is useful for customizing the style of the messages.
- `additional_rules`: Add custom rules to the translation prompt. This is useful for customizing the style of the messages or creating entirely new language styles.
Example configuration:
Expand Down

0 comments on commit a3d7937

Please sign in to comment.