mirror of
https://github.com/viliusle/miniPaint.git
synced 2026-02-06 07:56:44 +00:00
updated tool to extract translations
This commit is contained in:
parent
1e11f8d590
commit
1fed01dde0
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
global $LANGUAGES;
|
||||
|
||||
require_once(__DIR__ . '/libs/translator.php');
|
||||
$translator = new Translator();
|
||||
?>
|
||||
@ -20,7 +22,13 @@ $translator = new Translator();
|
||||
<br /><br />
|
||||
<b>Actions</b>:
|
||||
<input type="submit" name="action" value="Generate empty.json" />
|
||||
<input style="font-weight:bold;" type="submit" name="action" value="Auto Translate" />
|
||||
<input type="submit" name="action" value="Auto Translate: all" /> or
|
||||
|
||||
<?php
|
||||
foreach ($LANGUAGES as $lang) {
|
||||
echo '<button type="submit" name="action" value="Auto Translate: '.strtolower($lang).'">'.strtoupper($lang).'</button> ';
|
||||
}
|
||||
?>
|
||||
<br /><br />
|
||||
<?php
|
||||
if (count($_POST) > 0) {
|
||||
@ -54,13 +62,13 @@ $translator = new Translator();
|
||||
if ($_POST['action'] == 'Merge') {
|
||||
$translator->merge();
|
||||
}
|
||||
if ($_POST['action'] == 'Auto Translate') {
|
||||
if (stripos($_POST['action'], 'Auto Translate') !== false) {
|
||||
//prepare
|
||||
$translator->scan();
|
||||
$translator->extract();
|
||||
$translator->filter();
|
||||
|
||||
$translator->auto_translate();
|
||||
$translator->auto_translate($_POST['action']);
|
||||
}
|
||||
if ($_POST['action'] == 'Generate empty.json') {
|
||||
//prepare
|
||||
|
||||
@ -251,13 +251,22 @@ class Translator {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function auto_translate() {
|
||||
public function auto_translate($action_string) {
|
||||
global $LANGUAGES, $LANG_DIR;
|
||||
|
||||
$action_string = str_replace('Auto Translate: ', '', $action_string);
|
||||
if($action_string == 'all'){
|
||||
$action_string = '';
|
||||
}
|
||||
|
||||
$service = new GoogleTranslate();
|
||||
$text = implode("\n", $this->strings);
|
||||
|
||||
foreach ($LANGUAGES as $lang) {
|
||||
if($action_string != '' && $action_string != $lang){
|
||||
continue;
|
||||
}
|
||||
|
||||
echo "<br />$lang: ";
|
||||
|
||||
$file_path = $LANG_DIR . strtolower($lang) . ".json";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user