Add behavior intern i18n system

This commit is contained in:
2022-03-29 10:57:28 +08:00
parent 791b554ca0
commit b6f8828c3b
8 changed files with 71 additions and 17 deletions
@@ -1,8 +1,8 @@
import { Theme } from "@Component/Theme/Theme";
import { Component, ReactNode } from "react";
import { IRenderBehavior, Behavior, BehaviorRecorder } from "@Model/Behavior";
import { useSettingWithEvent, IMixinSettingProps } from "@Context/Setting";
import { Icon } from "@fluentui/react";
import { Localization } from "@Component/Localization/Localization";
import "./BehaviorList.scss";
interface IBehaviorListProps {
@@ -13,7 +13,8 @@ interface IBehaviorListProps {
actionType?: "info" | "delete";
}
class BehaviorList extends Component<IBehaviorListProps> {
@useSettingWithEvent("language")
class BehaviorList extends Component<IBehaviorListProps & IMixinSettingProps> {
private isFocus(behavior: IRenderBehavior): boolean {
if (this.props.focusBehaviors) {
@@ -57,10 +58,10 @@ class BehaviorList extends Component<IBehaviorListProps> {
</div>
}
private renderTerm(key: string, className: string, needLocal: boolean) {
private renderTerm(behavior: IRenderBehavior, key: string, className: string, needLocal: boolean) {
if (needLocal) {
return <div className={className}>
<Localization i18nKey={key as any}/>
{behavior.getTerms(key, this.props.setting?.language)}
</div>;
} else {
return <div className={className}>
@@ -117,8 +118,8 @@ class BehaviorList extends Component<IBehaviorListProps> {
<Icon iconName={icon}/>
</div>
<div className="behavior-content-view">
{this.renderTerm(name, "title-view", needLocal)}
{this.renderTerm(info, "info-view", needLocal)}
{this.renderTerm(behavior, name, "title-view", needLocal)}
{this.renderTerm(behavior, info, "info-view", needLocal)}
</div>
<div className="behavior-action-view">
{this.renderActionButton(behavior)}