i18n language generate

pull/813/head^2
hunterlong 2020-09-11 20:08:26 -07:00
parent f7aa35ce0e
commit b37713877a
13 changed files with 235 additions and 62 deletions

View File

@ -92,8 +92,8 @@
this.loading = true
const c = this.core
await Api.core_save(c)
const core = await Api.core()
this.$store.commit('setCore', core)
this.$store.commit('setCore', c)
this.$i18n.locale = c.language || "en";
this.loading = false
},
selectAll() {

View File

@ -11,15 +11,15 @@
</div>
</div>
<div class="form-group row">
<label for="service_type" class="col-sm-4 col-form-label">{{ $t('service.type') }}</label>
<label for="service_type" class="col-sm-4 col-form-label">{{ $t('service_type') }}</label>
<div class="col-sm-8">
<select v-model="service.type" class="form-control" id="service_type">
<option value="http">HTTP Service</option>
<option value="tcp">TCP Service</option>
<option value="udp">UDP Service</option>
<option value="http">HTTP {{ $t('service') }}</option>
<option value="tcp">TCP {{ $t('service') }}</option>
<option value="udp">UDP {{ $t('service') }}</option>
<option value="icmp">ICMP Ping</option>
<option value="grpc">gRPC Service</option>
<option value="static">Static Service</option>
<option value="grpc">gRPC {{ $t('service') }}</option>
<option value="static">Static {{ $t('service') }}</option>
</select>
<small class="form-text text-muted">Use HTTP if you are checking a website or use TCP if you are checking a server</small>
</div>
@ -35,7 +35,7 @@
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Permalink URL</label>
<label class="col-sm-4 col-form-label">{{ $t('permalink') }}</label>
<div class="col-sm-8">
<input v-model="service.permalink" type="text" name="permalink" class="form-control" id="permalink" autocapitalize="none" spellcheck="true" placeholder='awesome_service'>
<small class="form-text text-muted">Use text for the service URL rather than the service number.</small>
@ -43,7 +43,7 @@
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Public Service</label>
<label class="col-sm-4 col-form-label">{{ $t('service_public') }}</label>
<div class="col-12 col-md-8 mt-1 mb-2">
<span @click="service.public = !!service.public" class="switch float-left">
<input v-model="service.public" type="checkbox" name="public-option" class="switch" id="switch-public" v-bind:checked="service.public">
@ -54,7 +54,7 @@
</div>
<div v-if="service.type !== 'static'" class="form-group row">
<label for="service_interval" class="col-sm-4 col-form-label">Check Interval</label>
<label for="service_interval" class="col-sm-4 col-form-label">{{ $t('check_interval') }}</label>
<div class="col-sm-6">
<span class="slider-info">{{secondsHumanize(service.check_interval)}}</span>
<input v-model="service.check_interval" type="range" class="slider" id="service_interval" min="1" max="1800" :step="1">
@ -74,7 +74,7 @@
<div class="form-group row">
<label for="service_url" class="col-sm-4 col-form-label">
Service Endpoint {{service.type === 'http' ? "(URL)" : "(Domain)"}}
{{ $t('service_endpoint') }} {{service.type === 'http' ? "(URL)" : "(Domain)"}}
</label>
<div class="col-sm-8">
<input v-model="service.domain" type="url" class="form-control" id="service_url" :placeholder="service.type === 'http' ? 'https://google.com' : '192.168.1.1'" required autocapitalize="none" spellcheck="false">
@ -90,7 +90,7 @@
</div>
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
<label class="col-sm-4 col-form-label">Service Check Type</label>
<label class="col-sm-4 col-form-label">{{ $t('service_check') }}</label>
<div class="col-sm-8">
<select v-model="service.method" name="method" class="form-control">
<option value="GET" >GET</option>
@ -104,7 +104,7 @@
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Request Timeout</label>
<label class="col-sm-4 col-form-label">{{ $t('service_timeout') }}</label>
<div class="col-sm-6">
<span v-if="service.timeout >= 0" class="slider-info">{{secondsHumanize(service.timeout)}}</span>
<input v-model="service.timeout" type="range" id="timeout" name="timeout" class="slider" min="1" max="180">
@ -132,14 +132,14 @@
</div>
</div>
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
<label class="col-sm-4 col-form-label">Expected Response (Regex)</label>
<label class="col-sm-4 col-form-label">{{ $t('expected_resp') }} (Regex)</label>
<div class="col-sm-8">
<textarea v-model="service.expected" class="form-control" rows="3" autocapitalize="none" spellcheck="false" placeholder='(method)": "((\\"|[success])*)"'></textarea>
<small class="form-text text-muted">You can use plain text or insert <a target="_blank" href="https://regex101.com/r/I5bbj9/1">Regex</a> to validate the response</small>
</div>
</div>
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
<label for="service_response_code" class="col-sm-4 col-form-label">Expected Status Code</label>
<label for="service_response_code" class="col-sm-4 col-form-label">{{ $t('expected_code') }}</label>
<div class="col-sm-8">
<input v-model="service.expected_status" type="number" name="expected_status" class="form-control" placeholder="200" id="service_response_code">
<small class="form-text text-muted">A status code of 200 is success, or view all the <a target="_blank" href="https://www.restapitutorial.com/httpstatuscodes.html">HTTP Status Codes</a></small>
@ -147,7 +147,7 @@
</div>
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
<label class="col-12 col-md-4 col-form-label">Follow HTTP Redirects</label>
<label class="col-12 col-md-4 col-form-label">{{ $t('follow_redir') }}</label>
<div class="col-12 col-md-8 mt-1 mb-2 mb-md-0">
<span @click="service.redirect = !!service.redirect" class="switch float-left">
<input v-model="service.redirect" type="checkbox" name="redirect-option" class="switch" id="switch-redirect" v-bind:checked="service.redirect">
@ -157,7 +157,7 @@
</div>
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
<label class="col-12 col-md-4 col-form-label">Verify SSL</label>
<label class="col-12 col-md-4 col-form-label">{{ $t('verify_ssl') }}</label>
<div class="col-12 col-md-8 mt-1 mb-2 mb-md-0">
<span @click="service.verify_ssl = !!service.verify_ssl" class="switch float-left">
<input v-model="service.verify_ssl" type="checkbox" name="verify_ssl-option" class="switch" id="switch-verify-ssl" v-bind:checked="service.verify_ssl">
@ -168,7 +168,7 @@
</div>
<div v-if="service.type.match(/^(tcp|http)$/)" class="form-group row">
<label class="col-12 col-md-4 col-form-label">Use TLS Certificate</label>
<label class="col-12 col-md-4 col-form-label">{{ $t('tls_cert') }}</label>
<div class="col-12 col-md-8 mt-1 mb-2 mb-md-0">
<span @click="use_tls = !!use_tls" class="switch float-left">
<input v-model="use_tls" type="checkbox" name="verify_ssl-option" class="switch" id="switch-use-tls" v-bind:checked="use_tls">
@ -206,11 +206,11 @@
</div>
<div class="card contain-card mb-4">
<div class="card-header">Notification Options</div>
<div class="card-header">{{ $t('notification_opts') }}</div>
<div class="card-body">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Enable Notifications</label>
<label class="col-sm-4 col-form-label">{{ $t('notifications_enable') }}</label>
<div class="col-12 col-md-8 mt-1 mb-2 mb-md-0">
<span @click="service.allow_notifications = !!service.allow_notifications" class="switch float-left">
<input v-model="service.allow_notifications" type="checkbox" name="allow_notifications-option" class="switch" id="switch-notifications" v-bind:checked="service.allow_notifications">
@ -219,7 +219,7 @@
</div>
</div>
<div v-if="service.allow_notifications" class="form-group row">
<label class="col-sm-4 col-form-label">Notify After Failures</label>
<label class="col-sm-4 col-form-label">{{ $t('notify_after') }}</label>
<div class="col-sm-8">
<span class="slider-info">{{service.notify_after === 0 ? "First Failure" : service.notify_after+' Failures'}}</span>
<input v-model="service.notify_after" type="range" name="notify_after" class="slider" id="notify_after" min="0" max="20">
@ -227,7 +227,7 @@
</div>
</div>
<div v-if="service.allow_notifications" class="form-group row">
<label class="col-sm-4 col-form-label">Notify All Changes</label>
<label class="col-sm-4 col-form-label">{{ $t('notify_all') }}</label>
<div class="col-12 col-md-8 mt-1">
<span @click="service.notify_all_changes = !!service.notify_all_changes" class="switch float-left">
<input v-model="service.notify_all_changes" type="checkbox" name="notify_all-option" class="switch" id="notify_all" v-bind:checked="service.notify_all_changes">
@ -243,7 +243,7 @@
<div class="form-group row">
<div class="col-12">
<button :disabled="loading" @click.prevent="saveService" type="submit" class="btn btn-success btn-block">
{{service.id ? "Update Service" : "Create Service"}}
{{service.id ? $t('service_update') : $t('service_create')}}
</button>
</div>
</div>

View File

@ -110,7 +110,24 @@ const chinese = {
user_update: "更新用户",
administrator: "管理员",
checkins: "车臣金斯",
incidents: "事件"
incidents: "事件",
service_info: "服务信息",
service_name: "服务名称",
service_type: "服务类型",
permalink: "永久链接 URL",
service_public: "公共服务",
check_interval: "检查间隔",
service_endpoint: "服务终端节点",
service_check: "服务检查类型",
service_timeout: "请求超时",
expected_resp: "预期响应",
expected_code: "预期状态代码",
follow_redir: "跟随重定向",
verify_ssl: "验证 SSL",
tls_cert: "使用 TLS 证书",
notifications_enable: "启用通知",
notify_after: "故障后通知",
notify_all: "通知所有更改"
}
export default chinese

View File

@ -111,3 +111,23 @@ user_update,Update User
administrator,Administrator
checkins,Checkins
incidents,Incidents
service_info,Service Info
service_name,Service Name
service_type,Service Type
permalink,Permalink URL
service_public,Public Service
check_interval,Check Interval
service_endpoint,Service Endpoint
service_check,Service Check Type
service_timeout,Request Timeout
expected_resp,Expected Response
expected_code,Expected Status Code
follow_redir,Follow Redirects
verify_ssl,Verify SSL
tls_cert,Use TLS Cert
notification_opts,Notification Options
notifications_enable,Enable Notifications
notify_after,Notify After Failures
notify_all,Notify All Changes
service_update,Update Service
service_create,Create Service

1 key en
111 administrator Administrator
112 checkins Checkins
113 incidents Incidents
114 service_info Service Info
115 service_name Service Name
116 service_type Service Type
117 permalink Permalink URL
118 service_public Public Service
119 check_interval Check Interval
120 service_endpoint Service Endpoint
121 service_check Service Check Type
122 service_timeout Request Timeout
123 expected_resp Expected Response
124 expected_code Expected Status Code
125 follow_redir Follow Redirects
126 verify_ssl Verify SSL
127 tls_cert Use TLS Cert
128 notification_opts Notification Options
129 notifications_enable Enable Notifications
130 notify_after Notify After Failures
131 notify_all Notify All Changes
132 service_update Update Service
133 service_create Create Service

View File

@ -110,7 +110,24 @@ const english = {
user_update: "Update User",
administrator: "Administrator",
checkins: "Checkins",
incidents: "Incidents"
incidents: "Incidents",
service_info: "Service Info",
service_name: "Service Name",
service_type: "Service Type",
permalink: "Permalink URL",
service_public: "Public Service",
check_interval: "Check Interval",
service_endpoint: "Service Endpoint",
service_check: "Service Check Type",
service_timeout: "Request Timeout",
expected_resp: "Expected Response",
expected_code: "Expected Status Code",
follow_redir: "Follow Redirects",
verify_ssl: "Verify SSL",
tls_cert: "Use TLS Cert",
notifications_enable: "Enable Notifications",
notify_after: "Notify After Failures",
notify_all: "Notify All Changes"
}
export default english

View File

@ -110,7 +110,24 @@ const french = {
user_update: "Mise à jour utilisateur",
administrator: "Administrateur",
checkins: "Checkins",
incidents: "Incidents"
incidents: "Incidents",
service_info: "Informations sur le service",
service_name: "Nom du service",
service_type: "Type de service",
permalink: "URL Permalien",
service_public: "Fonction publique",
check_interval: "Période de vérification",
service_endpoint: "Point de terminaison de service",
service_check: "Type de vérification de service",
service_timeout: "Délai d'attente de",
expected_resp: "Réponse attendue",
expected_code: "Code d'état attendu",
follow_redir: "Suivre les redirections",
verify_ssl: "Vérifier SSL",
tls_cert: "Utiliser le certificat TLS",
notifications_enable: "Activer les notifications",
notify_after: "Notification après les échecs",
notify_all: "Notifier toutes les modifications"
}
export default french

View File

@ -110,7 +110,24 @@ const german = {
user_update: "Benutzer aktualisieren",
administrator: "Administrator",
checkins: "Checkins",
incidents: "Vorfälle"
incidents: "Vorfälle",
service_info: "Service-Info",
service_name: "Dienstname",
service_type: "Service-Art",
permalink: "Permalink-URL",
service_public: "Öffentlicher Dienst",
check_interval: "Intervall prüfen",
service_endpoint: "Service-Endpunkt",
service_check: "Service-Prüfungstyp",
service_timeout: "Zeitüberschreitung anfordern",
expected_resp: "Erwartete Antwort",
expected_code: "Erwarteter Statuscode",
follow_redir: "Weiterleitungen folgen",
verify_ssl: "SSL verifizieren",
tls_cert: "TLS-Zertifikat verwenden",
notifications_enable: "Benachrichtigungen aktivieren",
notify_after: "Benachrichtigung nach Fehlern",
notify_all: "Alle Änderungen benachrichtigen"
}
export default german

View File

@ -110,7 +110,24 @@ const italian = {
user_update: "Aggiorna utente",
administrator: "Amministratore",
checkins: "Check-ins",
incidents: "Incidenti"
incidents: "Incidenti",
service_info: "Info servizio",
service_name: "Nome servizio",
service_type: "Tipo di servizio",
permalink: "URL Permalink",
service_public: "Servizio pubblico",
check_interval: "Intervallo controllo",
service_endpoint: "Endpoint servizio",
service_check: "Tipo di controllo del servizio",
service_timeout: "Timeout richiesta",
expected_resp: "Risposta prevista",
expected_code: "Codice di stato previsto",
follow_redir: "Segui i reindirizzamenti",
verify_ssl: "Verifica SSL",
tls_cert: "Usa certificato TLS",
notifications_enable: "Abilita notifiche",
notify_after: "Notify dopo gli errori",
notify_all: "Notifichi tutte le modifiche"
}
export default italian

View File

@ -110,7 +110,24 @@ const japanese = {
user_update: "ユーザーの更新",
administrator: "管理者",
checkins: "チェックイン",
incidents: "事変"
incidents: "事変",
service_info: "サービス情報",
service_name: "サービス名",
service_type: "サービスタイプ",
permalink: "パーマリンクURL",
service_public: "公共サービス",
check_interval: "チェック間隔",
service_endpoint: "サービスエンドポイント",
service_check: "サービス・チェック・タイプ",
service_timeout: "リクエストのタイムアウト",
expected_resp: "期待される応答",
expected_code: "予想されるステータスコード",
follow_redir: "リダイレクトに従う",
verify_ssl: "SSL の確認",
tls_cert: "TLS 証明書を使用",
notifications_enable: "通知を有効にする",
notify_after: "障害発生後に通知する",
notify_all: "すべての変更を通知"
}
export default japanese

View File

@ -110,7 +110,24 @@ const korean = {
user_update: "사용자 업데이트",
administrator: "관리자",
checkins: "체크인",
incidents: "인시던트"
incidents: "인시던트",
service_info: "서비스 정보",
service_name: "서비스 이름",
service_type: "서비스 유형",
permalink: "영구 링크 URL",
service_public: "공공 서비스",
check_interval: "확인 간격",
service_endpoint: "서비스 엔드포인트",
service_check: "서비스 검사 유형",
service_timeout: "요청 시간 초과",
expected_resp: "예상 응답",
expected_code: "예상 상태 코드",
follow_redir: "리다이렉트 따르기",
verify_ssl: "SSL 확인",
tls_cert: "TLS 인증서 사용",
notifications_enable: "알림 활성화",
notify_after: "실패 후 알림",
notify_all: "모든 변경 사항 알림"
}
export default korean

View File

@ -110,7 +110,24 @@ const russian = {
user_update: "Обновить пользователя",
administrator: "Администратора",
checkins: "Чеккинс",
incidents: "Инциденты"
incidents: "Инциденты",
service_info: "Информация о сервисе",
service_name: "Имя службы",
service_type: "Тип услуги",
permalink: "URL-адрес Постоянной ссылки",
service_public: "Государственная служба",
check_interval: "Интервал проверки",
service_endpoint: "Конечная точка службы",
service_check: "Тип проверки службы",
service_timeout: "Тайм-аут запроса",
expected_resp: "Ожидаемый ответ",
expected_code: "Код ожидаемого состояния",
follow_redir: "Следуйте за перенаправленными",
verify_ssl: "Проверить SSL",
tls_cert: "Использовать сертификат TLS",
notifications_enable: "Включить уведомления",
notify_after: "Уведомлять после сбоев",
notify_all: "Уведомлять обо всех изменениях"
}
export default russian

View File

@ -110,7 +110,24 @@ const spanish = {
user_update: "Actualizar usuario",
administrator: "Administrador",
checkins: "Checkins",
incidents: "Incidentes"
incidents: "Incidentes",
service_info: "Información de servicio",
service_name: "Nombre del servicio",
service_type: "Tipo de servicio",
permalink: "URL de enlace permanente",
service_public: "Servicio Público",
check_interval: "Intervalo Comprobar",
service_endpoint: "Punto final de servicio",
service_check: "Tipo de comprobación de servicio",
service_timeout: "Tiempo de espera de solicitud",
expected_resp: "Respuesta esperada",
expected_code: "Código de estado esperado",
follow_redir: "Seguir redirecciones",
verify_ssl: "Verificar SSL",
tls_cert: "Usar Cert TLS",
notifications_enable: "Habilitar notificaciones",
notify_after: "Notificar después de errores",
notify_all: "Notificar todos los cambios"
}
export default spanish

View File

@ -34,41 +34,13 @@ type Text struct {
It string
}
func Translate(val, language string) string {
input := &translate.TextInput{
SourceLanguageCode: aws.String("en"),
TargetLanguageCode: aws.String(language),
Text: aws.String(val),
}
req, out := tr.TextRequest(input)
if err := req.Send(); err != nil {
panic(req.Error)
}
return *out.TranslatedText
}
func TranslateAll(key, en string) *Text {
return &Text{
Key: key,
En: en,
Fr: Translate(en, "fr"),
De: Translate(en, "de"),
Ru: Translate(en, "ru"),
Sp: Translate(en, "es"),
Jp: Translate(en, "ja"),
Cn: Translate(en, "zh"),
Ko: Translate(en, "ko"),
It: Translate(en, "it"),
}
}
func main() {
fmt.Println("RUNNING: ./source/generate_languages.go")
awsKey = os.Getenv("AWS_ACCESS_KEY_ID")
awsSecret = os.Getenv("AWS_SECRET_ACCESS_KEY")
if awsKey == "" || awsSecret == "" {
fmt.Println("AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY not set")
os.Exit(1)
os.Exit(0)
return
}
@ -119,6 +91,34 @@ func main() {
CreateJS("korean", translations)
}
func Translate(val, language string) string {
input := &translate.TextInput{
SourceLanguageCode: aws.String("en"),
TargetLanguageCode: aws.String(language),
Text: aws.String(val),
}
req, out := tr.TextRequest(input)
if err := req.Send(); err != nil {
panic(req.Error)
}
return *out.TranslatedText
}
func TranslateAll(key, en string) *Text {
return &Text{
Key: key,
En: en,
Fr: Translate(en, "fr"),
De: Translate(en, "de"),
Ru: Translate(en, "ru"),
Sp: Translate(en, "es"),
Jp: Translate(en, "ja"),
Cn: Translate(en, "zh"),
Ko: Translate(en, "ko"),
It: Translate(en, "it"),
}
}
func (t *Text) String(lang string) string {
switch lang {
case "english":