Some minor i18n react component cleanup
parent
0b5f519735
commit
79e67920a7
|
@ -5,9 +5,7 @@ import {parseMessageWithArguments} from "tc-shared/ui/frames/chat";
|
||||||
let instances = [];
|
let instances = [];
|
||||||
export class Translatable extends React.Component<{
|
export class Translatable extends React.Component<{
|
||||||
children: string | (string | React.ReactElement<HTMLBRElement>)[],
|
children: string | (string | React.ReactElement<HTMLBRElement>)[],
|
||||||
__cacheKey?: string,
|
|
||||||
trIgnore?: boolean,
|
trIgnore?: boolean,
|
||||||
enforceTextOnly?: boolean
|
|
||||||
}, { translated: string }> {
|
}, { translated: string }> {
|
||||||
protected renderElementIndex = 0;
|
protected renderElementIndex = 0;
|
||||||
|
|
||||||
|
@ -29,8 +27,9 @@ export class Translatable extends React.Component<{
|
||||||
render() {
|
render() {
|
||||||
return this.state.translated.split("\n").reduce((previousValue, currentValue, currentIndex, array) => {
|
return this.state.translated.split("\n").reduce((previousValue, currentValue, currentIndex, array) => {
|
||||||
previousValue.push(<React.Fragment key={++this.renderElementIndex}>{currentValue}</React.Fragment>);
|
previousValue.push(<React.Fragment key={++this.renderElementIndex}>{currentValue}</React.Fragment>);
|
||||||
if(currentIndex + 1 !== array.length)
|
if(currentIndex + 1 !== array.length) {
|
||||||
previousValue.push(<br key={++this.renderElementIndex} />);
|
previousValue.push(<br key={++this.renderElementIndex} />);
|
||||||
|
}
|
||||||
return previousValue;
|
return previousValue;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +51,7 @@ export class Translatable extends React.Component<{
|
||||||
|
|
||||||
let renderBrElementIndex = 0;
|
let renderBrElementIndex = 0;
|
||||||
export type VariadicTranslatableChild = React.ReactElement | string | number;
|
export type VariadicTranslatableChild = React.ReactElement | string | number;
|
||||||
export const VariadicTranslatable = (props: { text: string, __cacheKey?: string, children?: VariadicTranslatableChild[] | VariadicTranslatableChild }) => {
|
export const VariadicTranslatable = (props: { text: string, children?: VariadicTranslatableChild[] | VariadicTranslatableChild }) => {
|
||||||
const args = Array.isArray(props.children) ? props.children : [props.children];
|
const args = Array.isArray(props.children) ? props.children : [props.children];
|
||||||
const argsUseCount = [...new Array(args.length)].map(() => 0);
|
const argsUseCount = [...new Array(args.length)].map(() => 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue