-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto translate using Translation Engine #284
Open
timoye
wants to merge
17
commits into
joedixon:2.x
Choose a base branch
from
timoye:auto-translate
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8957ed4
auto translate command using google translate for free!
timoye a3dbb3b
register auto translate command
timoye 6ee520f
comments on methods
timoye 6909956
remove unused classes
timoye b5ce8af
how to use auto translate
timoye 55a8d64
how to use auto translate
timoye cc5af14
how to use auto translate
timoye 0ca3ea4
Auto translate command
timoye 7081aae
auto-translate value instead of key
q-- 3f00a8f
Merge pull request #1 from q--/Use_values_instead_of_keys_for_transla…
timoye f316aa4
Skip auto-translate if source language=target language
q-- 7df3ced
Tell Google Translate what the source language is
q-- 7ef311e
Fall back to key if no source language value
q-- 8b31883
You do not need to pass $this->sourceLanguage to GoogleTranslate
timoye eeb5f88
google translate comment
timoye 1d75854
comment
timoye 82320bd
Merge pull request #3 from q--/Fall_back_to_key_if_source_language_is…
timoye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace JoeDixon\Translation\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class AutoTranslateKeysCommand extends BaseCommand | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'translation:auto-translate {language?}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Auto translate keys using google translate'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$language = $this->argument('language') ?: false; | ||
try { | ||
// if we have a language, pass it in, if not the method will | ||
// automagically translate all languages | ||
$this->translation->autoTranslate($language); | ||
|
||
return $this->info(__('translation::translation.auto_translated')); | ||
} catch (\Exception $e) { | ||
return $this->error($e->getMessage()); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't strictly necessary to pass the source language, but it's my understanding that if you don't, Google Translate will try to guess the source language (it's set to
auto
). That can sometimes lead to wrong results if two languages have the same word with a different meaning, e.g. the word 'brand' means fire in Dutch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see. that is correct.
I didn't look at that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Thanks for your part of writing this pull request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is my pleasure.
It was quite helpful to me and I thought to let others use it also