allow more strings to be translated

pull/716/head
gabrielburnworth 2018-03-13 20:55:15 -07:00
parent 3d4f29df67
commit 9801f983a5
12 changed files with 84 additions and 52 deletions

View File

@ -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));

View File

@ -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));

View File

@ -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.`);

View File

@ -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) {
<ToggleButton
toggleValue={toggleValue}
toggleAction={onClick}
customText={{ textFalse: "off", textTrue: "on" }}
customText={{ textFalse: t("off"), textTrue: t("on") }}
disabled={disabled} />
</Col>
</Row>;

View File

@ -45,8 +45,8 @@ export class Move extends React.Component<MoveProps, {}> {
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 <Widget>
<WidgetHeader

View File

@ -11,7 +11,7 @@ export class EStopButton extends React.Component<EStopButtonProps, {}> {
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 <button

View File

@ -5,6 +5,7 @@ import { Row, Col } from "../../ui/index";
import { settingToggle } from "../actions";
import { ToggleButton } from "../../controls/toggle_button";
import { isUndefined } from "util";
import { t } from "i18next";
export function PinGuardMCUInputGroup(props: PinGuardMCUInputGroupProps) {
@ -36,7 +37,7 @@ export function PinGuardMCUInputGroup(props: PinGuardMCUInputGroupProps) {
</Col>
<Col xs={2} className={"centered-button-div"}>
<ToggleButton
customText={{ textFalse: "low", textTrue: "high" }}
customText={{ textFalse: t("low"), textTrue: t("high") }}
toggleValue={inactiveState}
dim={!sourceFwConfig(activeState).consistent}
toggleAction={() => dispatch(settingToggle(activeState, sourceFwConfig))} />

View File

@ -1,43 +1,44 @@
import { trim } from "../../util";
import { t } from "i18next";
export namespace DiagnosticMessages {
// "SCV good to go, sir." is also appropriate.
export const OK = "All systems nominal.";
export const OK = t("All systems nominal.");
export const MISC = trim(`Some other issue is preventing FarmBot from
working. Please see the table above for more information.`);
export const MISC = trim(t(`Some other issue is preventing FarmBot from
working. Please see the table above for more information.`));
export const TOTAL_BREAKAGE = trim(`There is no access to FarmBot or the
export const TOTAL_BREAKAGE = trim(t(`There is no access to FarmBot or the
message broker. This is usually caused by outdated browsers
(Internet Explorer) or firewalls that block WebSockets on port 3002.`);
(Internet Explorer) or firewalls that block WebSockets on port 3002.`));
export const REMOTE_FIREWALL = trim(`FarmBot and the browser are both
export const REMOTE_FIREWALL = trim(t(`FarmBot and the browser are both
connected to the internet (or have been recently). Try rebooting FarmBot
and refreshing the browser. If the issue persists, something may be
preventing FarmBot from accessing the message broker (used to communicate
with your web browser in real-time). If you are on a company or school
network, a firewall may be blocking port 5672.`);
network, a firewall may be blocking port 5672.`));
export const WIFI_OR_CONFIG = trim(`Your browser is connected correctly,
export const WIFI_OR_CONFIG = trim(t(`Your browser is connected correctly,
but we have no recent record of FarmBot connecting to the internet.
This usually happens because of a bad WiFi signal in the garden, a bad
password during configuration, or a very long power outage.`);
password during configuration, or a very long power outage.`));
export const NO_WS_AVAILABLE = trim(`You are either offline, using a web
export const NO_WS_AVAILABLE = trim(t(`You are either offline, using a web
browser that does not support WebSockets, or are behind a firewall that
blocks port 3002. Do not attempt to debug FarmBot hardware until you solve
this issue first. You will not be able to troubleshoot hardware issues
without a reliable browser and internet connection.`);
without a reliable browser and internet connection.`));
export const INACTIVE = trim(`FarmBot and the browser both have internet
export const INACTIVE = trim(t(`FarmBot and the browser both have internet
connectivity, but we haven't seen any activity from FarmBot on the Web
App in a while. This could mean that FarmBot has not synced in a while,
which might not be a problem. If you are experiencing usability issues,
however, it could be a sign of HTTP blockage on FarmBot's local internet
connection.`);
connection.`));
export const ARDUINO_DISCONNECTED = trim(`Arduino is possibly unplugged.
export const ARDUINO_DISCONNECTED = trim(t(`Arduino is possibly unplugged.
Check the USB cable between the Raspberry Pi and the Arduino. Reboot
FarmBot after a reconnection. If the issue persists, reconfiguration
of FarmBot OS may be necessary.`);
of FarmBot OS may be necessary.`));
}

View File

@ -18,17 +18,17 @@ interface LogSettingRecord {
const SEQUENCE_LOG_SETTINGS: LogSettingRecord[] = [
{
label: "Begin",
label: t("Begin"),
setting: "sequence_init_log",
tooltip: ToolTips.SEQUENCE_LOG_BEGIN
},
{
label: "Steps",
label: t("Steps"),
setting: "sequence_body_log",
tooltip: ToolTips.SEQUENCE_LOG_STEP
},
{
label: "Complete",
label: t("Complete"),
setting: "sequence_complete_log",
tooltip: ToolTips.SEQUENCE_LOG_END
}
@ -36,17 +36,17 @@ const SEQUENCE_LOG_SETTINGS: LogSettingRecord[] = [
const FIRMWARE_LOG_SETTINGS: LogSettingRecord[] = [
{
label: "Sent",
label: t("Sent"),
setting: "firmware_output_log",
tooltip: ToolTips.FIRMWARE_LOG_SENT
},
{
label: "Received",
label: t("Received"),
setting: "firmware_input_log",
tooltip: ToolTips.FIRMWARE_LOG_RECEIVED
},
{
label: "Debug",
label: t("Debug"),
setting: "arduino_debug_messages",
tooltip: ToolTips.FIRMWARE_DEBUG_MESSAGES
},

View File

@ -4,6 +4,7 @@ import { Link } from "react-router";
import { ToolTips } from "../../constants";
import { StepWrapper, StepHeader, StepContent } from "../step_ui";
import { Col, Row } from "../../ui/index";
import { t } from "i18next";
export function TileTakePhoto({
dispatch, currentStep, index, currentSequence }: StepParams) {
@ -20,8 +21,8 @@ export function TileTakePhoto({
<Row>
<Col xs={12}>
<p>
Photos are viewable from the <Link to="/app/farmware">
farmware page</Link>.
{t("Photos are viewable from the")} <Link to="/app/farmware">
farmware {t("page")}</Link>.
</p>
</Col>
</Row>

View File

@ -23,7 +23,7 @@ export class ToolBayList extends React.Component<ToolBayListProps, {}> {
<ToolBayHeader />
{getToolSlots().map((slot: TaggedToolSlotPointer, index: number) => {
const tool = getToolByToolSlotUUID(slot.uuid);
const name = (tool && tool.body.name) || "None";
const name = (tool && tool.body.name) || t("None");
return <Row key={slot.uuid}>
<Col xs={1}>
<label>{index + 1}</label>

View File

@ -27,8 +27,8 @@ export function SaveBtn(props: SaveBtnProps) {
};
const CAPTIONS: Partial<Record<SpecialStatus, string>> = {
[SpecialStatus.DIRTY]: (t(props.dirtyText || "Save ") + " *"),
[SpecialStatus.SAVING]: t(props.savingText || "Saving")
[SpecialStatus.DIRTY]: (props.dirtyText || t("Save") + " *"),
[SpecialStatus.SAVING]: props.savingText || t("Saving")
};
const { savedText, onClick, hidden } = props;
@ -38,6 +38,6 @@ export function SaveBtn(props: SaveBtnProps) {
spinner : "";
return <button onClick={onClick} hidden={!!hidden} className={klass} >
{CAPTIONS[props.status] || (t(savedText || "Saved ") + " ✔")} {spinnerEl}
{CAPTIONS[props.status] || (savedText || t("Saved") + " ✔")} {spinnerEl}
</button>;
}