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