PHP code example of kargnas / laravel-ai-translator
1. Go to this page and download the library: Download kargnas/laravel-ai-translator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kargnas / laravel-ai-translator example snippets
'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",
],
],
return [
'notifications' => [
'new_feature_search_sentence' => 'New feature: Now you can type sentences not only words. Even in your languages. The AI will translate them to Chinese.',
'refresh_after_1_min' => 'Refresh after 1 minutes. New content will be available! (The previous model: :model, Updated: :updated_at)',
]
];
return array (
'notifications.new_feature_search_sentence' => '새로운 기능: 이제 단어뿐만 아니라 문장도 입력할 수 있어요. 심지어 여러분의 언어로도 가능해요.',
'notifications.refresh_after_1_min' => '1분 후에 새로고침하세요. 새로운 내용이 준비될 거예요! (이전 모델: :model, 업데이트: :updated_at)',
);
return array (
'notifications.new_feature_search_sentence' => '혁명적 새로운 기능: 동무들! 이제 단어뿐만 아니라 문장도 입력하여 단어의 력사를 확인할 수 있습니다. 모국어로도 괜찮습니다. 인공지능이 중국어로 번역해드리겠습니다.',
'notifications.refresh_after_1_min' => '1분후에 새로고침하십시요. 새로운 내용을 볼수 있습니다! (이전 모델: :model, 갱신: :updated_at)',
);
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)',
);
return [
'source_directory' => 'lang',
'ai' => [
'provider' => 'openai', // or 'anthropic'
'model' => 'gpt-4o', // or 'gpt-4', 'gpt-3.5-turbo', 'claude-3-5-sonnet-20240620'
'api_key' => env('OPENAI_API_KEY'), // or env('ANTHROPIC_API_KEY')
],
'locale_names' => [
'en' => 'English',
'ko' => 'Korean',
'zh_cn' => 'Chinese (Simplified)',
// ... other locales
],
'additional_rules' => [
'default' => [
"Use a friendly and intuitive tone of voice, like the service tone of voice of 'Discord'.",
],
'ko' => [
"한국의 인터넷 서비스 '토스'의 서비스 말투 처럼, 유저에게 친근하고 직관적인 말투로 설명하고 존댓말로 설명하세요.",
],
],
];