Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
4e138635
Commit
4e138635
authored
13 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Work on Google API v2
parent
5d5af4cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dev/translation/autotranslator.class.php
+4
-2
4 additions, 2 deletions
dev/translation/autotranslator.class.php
dev/translation/autotranslator.php
+7
-6
7 additions, 6 deletions
dev/translation/autotranslator.php
with
11 additions
and
8 deletions
dev/translation/autotranslator.class.php
+
4
−
2
View file @
4e138635
...
...
@@ -291,9 +291,11 @@ class autoTranslator
$src_text_to_translate
=
preg_replace
(
'/'
.
preg_quote
(
'\n\n'
)
.
'/'
,
' NNNNN '
,
$src_text_to_translate
);
// Define GET URL v1
$url
=
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="
.
urlencode
(
$src_text_to_translate
)
.
"&langpair="
.
urlencode
(
$lang_pair
);
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
// Define GET URL v2
// Example: "https://www.googleapis.com/language/translate/v2?key=".$this->apikey."&q=".urlencode($src_text_to_translate)."&source=".$src_lang."&target=".$dest_lang
$url
=
"https://www.googleapis.com/language/translate/v2?key="
.
$this
->
apikey
.
"&q="
.
urlencode
(
$src_text_to_translate
)
.
"&source="
.
urlencode
(
$src_lang
)
.
"&target="
.
urlencode
(
$dest_lang
);
// Example: https://www.googleapis.com/language/translate/v2?key=APIKEY&q=Setup%20area&source=en_US&target=fr_FR
// Send request
print
"Url to translate: "
.
$url
.
"
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
dev/translation/autotranslator.php
+
7
−
6
View file @
4e138635
...
...
@@ -56,8 +56,8 @@ $dir=DOL_DOCUMENT_ROOT."/langs";
// Check parameters
if
(
!
isset
(
$argv
[
2
]))
{
print
"Usage: "
.
$script_file
.
" lang_code_src lang_code_dest|all [langfile.lang]
\n
"
;
print
"Example: "
.
$script_file
.
" en_US pt_PT
\n
"
;
print
"Usage: "
.
$script_file
.
" lang_code_src lang_code_dest|all
APIKEY
[langfile.lang]
\n
"
;
print
"Example: "
.
$script_file
.
" en_US pt_PT
123456
\n
"
;
print
"Rem: lang_code to use can be found on http://www.google.com/language_tools
\n
"
;
exit
;
}
...
...
@@ -65,11 +65,12 @@ if (! isset($argv[2])) {
// Show parameters
print
'Argument 1='
.
$argv
[
1
]
.
"
\n
"
;
print
'Argument 2='
.
$argv
[
2
]
.
"
\n
"
;
print
'Argument 3='
.
$argv
[
3
]
.
"
\n
"
;
$file
=
''
;
if
(
isset
(
$argv
[
3
]))
if
(
isset
(
$argv
[
4
]))
{
$file
=
$argv
[
3
];
print
'Argument
3
='
.
$argv
[
3
]
.
"
\n
"
;
$file
=
$argv
[
4
];
print
'Argument
4
='
.
$argv
[
4
]
.
"
\n
"
;
}
print
'Files will be generated/updated in directory '
.
$dir
.
"
\n
"
;
...
...
@@ -89,7 +90,7 @@ if ($argv[2] != 'all')
require_once
(
DOL_DOCUMENT_ROOT
.
"/../dev/translation/autotranslator.class.php"
);
$langParser
=
new
autoTranslator
(
$argv
[
2
],
$argv
[
1
],
$dir
,
$file
,
$a
pikey
);
$langParser
=
new
autoTranslator
(
$argv
[
2
],
$argv
[
1
],
$dir
,
$file
,
$a
rgv
[
3
]
);
print
"***** Finished *****
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment