From 9801f983a52dba5b1f183599c0956919cd12cd33 Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Tue, 13 Mar 2018 20:55:15 -0700 Subject: [PATCH] allow more strings to be translated --- public/app-resources/languages/_helper.js | 9 +++-- .../account/labs/labs_features_list_data.ts | 26 +++++---------- webpack/constants.ts | 33 +++++++++++++++++++ webpack/controls/key_val_show_row.tsx | 3 +- webpack/controls/move.tsx | 4 +-- webpack/devices/components/e_stop_btn.tsx | 2 +- .../components/pin_guard_input_group.tsx | 3 +- .../connectivity/diagnostic_messages.ts | 31 ++++++++--------- webpack/logs/components/settings_menu.tsx | 12 +++---- .../sequences/step_tiles/tile_take_photo.tsx | 5 +-- webpack/tools/components/toolbay_list.tsx | 2 +- webpack/ui/save_button.tsx | 6 ++-- 12 files changed, 84 insertions(+), 52 deletions(-) diff --git a/public/app-resources/languages/_helper.js b/public/app-resources/languages/_helper.js index ea0c34d35..f21ab45a3 100644 --- a/public/app-resources/languages/_helper.js +++ b/public/app-resources/languages/_helper.js @@ -41,10 +41,10 @@ var HelperNamespace = (function () { // '.t("")' or '{t("")' or ' t("")' or '(t("")' or // '.t(``)' or '{t(``)' or ' t(``)' or '(t(``)' - var T_REGEX = /[.{(\s]t\(["`]([\w\s{}().,:'\-=\\?!]*)["`].*\)/g; + var T_REGEX = /[.{(\s]t\(["`]([\w\s{}().,:'\-=\\?\/%!]*)["`].*\)/g; // '``' - var C_REGEX = /[`]([\w\s{}().,:'\-=\\?!]*)[`].*/g; + var C_REGEX = /[`]([\w\s{}().,:'\-=\\?"+!]*)[`].*/g; /** * Get all the tags in the files with extension .ts of the current project @@ -61,7 +61,10 @@ var HelperNamespace = (function () { //flatten list of list in a simple list var flatAllTags = [].concat.apply([], allTags); var flatConstantsTags = [].concat.apply([], constantsTags); - var flattenedTags = [].concat.apply([], [flatAllTags, flatConstantsTags]); + var flatExtraTags = [].concat.apply([], + ["DISCONNECTED", "Controls", "Device", "Farm Designer"]); + var flattenedTags = [].concat.apply([], + [flatAllTags, flatConstantsTags, flatExtraTags]); //distinct var uniq = Array.from(new Set(flattenedTags)); diff --git a/webpack/account/labs/labs_features_list_data.ts b/webpack/account/labs/labs_features_list_data.ts index a0276b792..e0a3777a5 100644 --- a/webpack/account/labs/labs_features_list_data.ts +++ b/webpack/account/labs/labs_features_list_data.ts @@ -1,8 +1,8 @@ import { Session } from "../../session"; -import { trim } from "../../util"; import { t } from "i18next"; import { BooleanConfigKey } from "../../config_storage/web_app_configs"; import { BooleanSetting } from "../../session_keys"; +import { Content } from "../../constants"; export interface LabsFeature { /** Toggle label. */ @@ -32,55 +32,47 @@ export const fetchLabFeatures = (): LabsFeature[] => ([ }, { name: t("Confirm Sequence step deletion"), - description: trim(t(`Show a confirmation dialog when the sequence delete step - icon is pressed.`)), + description: t(Content.CONFIRM_STEP_DELETION), storageKey: BooleanSetting.confirm_step_deletion, value: false }, { name: t("Hide Webcam widget"), - description: trim(t(`If not using a webcam, use this setting to remove the - widget from the Controls page.`)), + description: t(Content.HIDE_WEBCAM_WIDGET), storageKey: BooleanSetting.hide_webcam_widget, value: false }, { name: t("Dynamic map size"), - description: trim(t(`Change the Farm Designer map size based on axis length. - A value must be input in AXIS LENGTH and STOP AT MAX must be enabled in - the HARDWARE widget.`)), + description: t(Content.DYNAMIC_MAP_SIZE), storageKey: BooleanSetting.dynamic_map, value: false }, { name: t("Double default map dimensions"), - description: trim(t(`Double the default dimensions of the Farm Designer map - for a map with four times the area.`)), + description: t(Content.DOUBLE_MAP_DIMENSIONS), storageKey: BooleanSetting.map_xl, value: false }, { name: t("Display plant animations"), - description: trim(t(`Enable plant animations in the Farm Designer.`)), + description: t(Content.PLANT_ANIMATIONS), storageKey: BooleanSetting.disable_animations, value: false, displayInvert: true }, { name: t("Read speak logs in browser"), - description: trim(t(`Have the browser also read aloud log messages on the - "Speak" channel that are spoken by FarmBot.`)), + description: t(Content.BROWSER_SPEAK_LOGS), storageKey: BooleanSetting.enable_browser_speak, value: false }, { name: t("Discard Unsaved Changes"), - description: trim(t(`Don't ask about saving work before - closing browser tab. Warning: may cause loss of data.`)), + description: t(Content.DISCARD_UNSAVED_CHANGES), storageKey: BooleanSetting.discard_unsaved, value: false, - confirmationMessage: trim(t(`Warning! When enabled, any unsaved changes - will be discarded when refreshing or closing the page. Are you sure?`)) + confirmationMessage: t(Content.DISCARD_UNSAVED_CHANGES_CONFIRM) }, ].map(fetchRealValue)); diff --git a/webpack/constants.ts b/webpack/constants.ts index 3cfdc1f85..2fbb621b4 100644 --- a/webpack/constants.ts +++ b/webpack/constants.ts @@ -308,6 +308,39 @@ export namespace Content { trim(`If you are sure you want to delete your account, type in your password below to continue.`); + // App Settings + export const CONFIRM_STEP_DELETION = + trim(`Show a confirmation dialog when the sequence delete step + icon is pressed.`); + + export const HIDE_WEBCAM_WIDGET = + trim(`If not using a webcam, use this setting to remove the + widget from the Controls page.`); + + export const DYNAMIC_MAP_SIZE = + trim(`Change the Farm Designer map size based on axis length. + A value must be input in AXIS LENGTH and STOP AT MAX must be enabled in + the HARDWARE widget.`); + + export const DOUBLE_MAP_DIMENSIONS = + trim(`Double the default dimensions of the Farm Designer map + for a map with four times the area.`); + + export const PLANT_ANIMATIONS = + trim(`Enable plant animations in the Farm Designer.`); + + export const BROWSER_SPEAK_LOGS = + trim(`Have the browser also read aloud log messages on the + "Speak" channel that are spoken by FarmBot.`); + + export const DISCARD_UNSAVED_CHANGES = + trim(`Don't ask about saving work before + closing browser tab. Warning: may cause loss of data.`); + + export const DISCARD_UNSAVED_CHANGES_CONFIRM = + trim(`Warning! When enabled, any unsaved changes + will be discarded when refreshing or closing the page. Are you sure?`); + // Device export const NOT_HTTPS = trim(`WARNING: Sending passwords via HTTP:// is not secure.`); diff --git a/webpack/controls/key_val_show_row.tsx b/webpack/controls/key_val_show_row.tsx index b586ca25f..20c7afb9e 100644 --- a/webpack/controls/key_val_show_row.tsx +++ b/webpack/controls/key_val_show_row.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import { Row, Col } from "../ui/index"; import { ToggleButton } from "./toggle_button"; +import { t } from "i18next"; export interface KeyValRowProps { label: string; @@ -27,7 +28,7 @@ export function KeyValShowRow(p: KeyValRowProps) { ; diff --git a/webpack/controls/move.tsx b/webpack/controls/move.tsx index 5d2b48d7e..4a3dc60e7 100644 --- a/webpack/controls/move.tsx +++ b/webpack/controls/move.tsx @@ -45,8 +45,8 @@ export class Move extends React.Component { const scaled_encoder_label = minFwVersionCheck(firmware_version, "5.0.5") - ? "Scaled Encoder (mm)" - : "Scaled Encoder (steps)"; + ? t("Scaled Encoder (mm)") + : t("Scaled Encoder (steps)"); return { const toggleEmergencyLock = isLocked ? emergencyUnlock : emergencyLock; const color = isLocked ? "yellow" : "red"; const emergencyLockStatusColor = isBotUp(i.sync_status) ? color : "gray"; - const emergencyLockStatusText = isLocked ? "UNLOCK" : "E-STOP"; + const emergencyLockStatusText = isLocked ? t("UNLOCK") : "E-STOP"; if (this.props.user) { return ; }