Translation generation command (#10794)

additional translatable strings: Filter Settings in settings page and Global Search on all pages.
remove duplicate fr key
also, language file signatures were wrong as I had a testing version of the vue generator
This commit is contained in:
Tony Murray
2019-11-09 13:01:41 +00:00
committed by GitHub
parent 90bd2275cf
commit 8bc0af7b85
8 changed files with 87 additions and 11 deletions

View File

@@ -0,0 +1,67 @@
<?php
/**
* TranslationGenerateCommand.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2019 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Console\Commands;
use App\Console\LnmsCommand;
use Storage;
use Symfony\Component\Process\Process;
class TranslationGenerateCommand extends LnmsCommand
{
protected $name = 'translation:generate';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Artisan::call('vue-i18n:generate', ['--multi-locales' => 'true', '--format' => 'umd']);
$npm = new Process(['npm', 'run', 'production']);
$npm->run();
if ($npm->getExitCode() !== 0) {
// npm failed, update hashes manually
$this->updateManifest();
}
return 0;
}
private function updateManifest()
{
$manifest_file = public_path('mix-manifest.json');
$manifest = json_decode(file_get_contents($manifest_file), true);
foreach (glob(public_path('js/lang/*.js')) as $file) {
$file_name = str_replace(public_path(), '', $file);
$manifest[$file_name] = $file_name . '?id=' . substr(md5(file_get_contents($file)), 0, 20);
}
file_put_contents($manifest_file, json_encode($manifest, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
}
}

View File

@@ -21,8 +21,7 @@ The config definition system inherently supports translation. You must add the E
To update the javascript translation files, run:
./lnms vue-i18n:generate --multi-locales --format=umd
npm run production
./lnms translation:generate
# Definition Format

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,12 @@
{
"/js/app.js": "/js/app.js?id=6db986ee2004e2d0968e",
"/js/app.js": "/js/app.js?id=a3314d8fe69b9133f906",
"/css/app.css": "/css/app.css?id=17e56994706c74ee9663",
"/js/manifest.js": "/js/manifest.js?id=3c768977c2574a34506e",
"/js/vendor.js": "/js/vendor.js?id=dc98201378abb0b1bb08"
"/js/vendor.js": "/js/vendor.js?id=dc98201378abb0b1bb08",
"/js/lang/de.js": "/js/lang/de.js?id=e0623715e8df0895188b",
"/js/lang/en.js": "/js/lang/en.js?id=aff7ae7d47d302882216",
"/js/lang/fr.js": "/js/lang/fr.js?id=cc96d231eaa8d18a851c",
"/js/lang/ru.js": "/js/lang/ru.js?id=b007ddce75134acbe635",
"/js/lang/uk.js": "/js/lang/uk.js?id=146819d3cf1dfb16672d",
"/js/lang/zh-TW.js": "/js/lang/zh-TW.js?id=7819eeabdcc9a65ffe73"
}

View File

@@ -27,7 +27,7 @@
<template v-slot:header>
<form class="form-inline" @submit.prevent>
<div class="input-group">
<input id="settings-search" type="search" class="form-control" placeholder="Filter Settings" v-model.trim="search_phrase">
<input id="settings-search" type="search" class="form-control" :placeholder="$t('Filter Settings')" v-model.trim="search_phrase">
</div>
</form>
</template>

View File

@@ -33,4 +33,7 @@ return [
'success' => 'Successfully added user: :username',
'wrong-auth' => 'Warning! You will not be able to log in with this user because you are not using MySQL auth',
],
'translation:generate' => [
'description' => 'Generate updated json language files for use in the web frontend',
]
];

View File

@@ -117,6 +117,7 @@
"My Settings": "Mes Paramètres",
"Settings": "Paramètres",
"Global Settings": "Paramètres globaux",
"Global Search": "Recherché globaux",
"Validate Config": "Valider la configuration",
"Auth History": "Historique d'authentification",
"Peering": "Peering",
@@ -361,7 +362,6 @@
"All Ports": "Tous les ports",
"Total": "Total",
"Ignored": "Ignoré",
"Disabled": "Désactiver",
"Errored": "Erreurs",
"Services": "Services",
"No devices found within interval.": "Aucun appareil découvert dans lintervalle.",
@@ -375,5 +375,6 @@
"Pollers": "Sondeurs",
"Groups": "Groupes",
"Performance": "Performance",
"History": "Historique"
"History": "Historique",
"Filter Settings": "Paramètres de filtre"
}

View File

@@ -465,7 +465,7 @@
@csrf
<div class="form-group">
<input class="form-control typeahead" type="search" id="gsearch" name="gsearch"
placeholder="Global Search" autocomplete="off">
placeholder="@lang('Global Search')" autocomplete="off">
</div>
</form>
<ul class="nav navbar-nav navbar-right">