本文整理匯總了TypeScript中@lingui/react.i18nMark函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript i18nMark函數的具體用法?TypeScript i18nMark怎麽用?TypeScript i18nMark使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了i18nMark函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: i18nMark
args.forEach((arg, index) => {
if (arg === "" || arg == undefined) {
errors.push({
path: ["job", "run", "args", `${index}`],
message: i18nMark("Arg cannot be empty.")
});
}
});
示例2: validateFormLabels
export function validateFormLabels(jobSpec: JobSpec): FormError[] {
const labels = (jobSpec.job.labels || []).map(([k]) => k);
const message = i18nMark("Cannot have multiple labels with the same key.");
return pipe(
allUniq(_ => "job.labels", [labels], message),
isUniqIn(labels)(i => `job.labels.${i}`, labels, message)
)([]);
}
示例3: formatServicePlanStatus
export function formatServicePlanStatus(status: ServicePlanStatus): string {
switch (status) {
case "ERROR":
return i18nMark("Error");
case "WAITING":
return i18nMark("Waiting");
case "PENDING":
return i18nMark("Pending");
case "PREPARED":
return i18nMark("Prepared");
case "STARTING":
return i18nMark("Starting");
case "STARTED":
return i18nMark("Started");
case "COMPLETE":
return i18nMark("Complete");
case "IN_PROGRESS":
return i18nMark("In Progress");
}
}
示例4: toCategoryLabel
function toCategoryLabel(category: StatusCategory): string {
switch (category) {
case StatusCategory.NA:
return i18nMark("N/A");
case StatusCategory.STOPPED:
return i18nMark("Stopped");
case StatusCategory.RUNNING:
return i18nMark("Running");
case StatusCategory.LOADING:
return i18nMark("Processing");
case StatusCategory.WARNING:
return i18nMark("Warning");
case StatusCategory.ERROR:
return i18nMark("Error");
}
}
示例5: flatMap
isValid: (val: T) => boolean,
defaultMessage: string
) => (path: (i: number) => string, values: T[], message = defaultMessage) => (
errors: FormError[]
) =>
errors.concat(
flatMap(
(value, index) =>
isValid(value) ? [] : [{ message, path: path(index).split(".") }],
values
)
);
const isBoolean = validation<boolean | undefined>(
x => x === undefined || typeof x === "boolean",
i18nMark("Must be a boolean.")
);
const isNumber = validation<number | undefined>(
x => x === undefined || typeof x === "number",
i18nMark("Must be a number.")
);
const isObject = validation<object | undefined>(
x => x === undefined || isObjectUtil(x),
i18nMark("Must be an object.")
);
const isPresent = validation<any>(
x => x !== undefined && x !== "",
i18nMark("Must be present.")
);
const isString = validation<string | undefined>(
x => x === undefined || typeof x === "string",
示例6: i18nMark
ERROR = "ERROR"
}
interface Status {
displayName: string;
category: StatusCategory;
priority: number;
}
///////////////////////////////////////////////////////////////////////////////
// ERRORS //
///////////////////////////////////////////////////////////////////////////////
const CREATION_ERROR: Status = {
priority: 32,
displayName: i18nMark("Error Creating Service"),
category: StatusCategory.ERROR
};
const UNAVAILABLE = {
priority: 31,
displayName: i18nMark("Service Unavailable"),
category: StatusCategory.ERROR
};
const ERROR = {
priority: 30,
displayName: i18nMark("Error"),
category: StatusCategory.ERROR
};
///////////////////////////////////////////////////////////////////////////////
// WARNINGS //
示例7: i18nMark
import { i18nMark } from "@lingui/react";
interface ServiceActionLabelsInterface {
edit: string;
delete: string;
restart: string;
resume: string;
open: string;
scale: string;
scale_by: string;
stop: string;
}
const ServiceActionLabels: ServiceActionLabelsInterface = {
edit: i18nMark("Edit"),
delete: i18nMark("Delete"),
restart: i18nMark("Restart"),
resume: i18nMark("Resume"),
open: i18nMark("Open Service"),
scale: i18nMark("Scale"),
scale_by: i18nMark("Scale By"),
stop: i18nMark("Stop")
};
export default ServiceActionLabels;