<commit_before>/* eslint react/prefer-stateless-function: "off" */
/* Because stateless functions don't have context it seems */
import React from 'react';
import { connect } from 'react-redux';
import en from './en';
import es from './es';
import fr from './fr';
import hu from './hu';
import ptbr from './pt-br';
import nl from './nl';
import ru from './ru';
import zhtw from './zh-tw';
import zhcn from './zh-cn';

//const languages = { en, es, fr, hu, ptbr, nl, ru, zhtw, zhcn };
const languages = { en, zhcn };

export default function translate(key) {
    return Component => {
        const stateToProps = state => ({
            currentLanguage: state.user.lang
        });

        class TranslationComponent extends React.Component {
            render() {
                const strings = languages[this.props.currentLanguage][key];
                const merged = {
                    ...this.props.strings,
                    ...strings
                };
                if (strings) {
                    return (
                        <Component {...this.props}
                          strings={merged}
                          currentLanguage={this.props.currentLanguage}
                        />
                    );
                }

                return (
                    <Component {...this.props}
                      currentLanguage={this.props.currentLanguage}
                    />
                );
            }
        }<commit_msg>改为英语和简体中文两种语言<commit_after>/* eslint react/prefer-stateless-function: "off" */
/* Because stateless functions don't have context it seems */
import React from 'react';
import { connect } from 'react-redux';
import en from './en';
/* import es from './es';
import fr from './fr';
import hu from './hu';
import ptbr from './pt-br';
import nl from './nl';
import ru from './ru';
import zhtw from './zh-tw'; */
import zhcn from './zh-cn';

/* const languages = { en, es, fr, hu, ptbr, nl, ru, zhtw, zhcn }; */
const languages = { en, zhcn };

export default function translate(key) {
    return Component => {
        const stateToProps = state => ({
            currentLanguage: state.user.lang
        });

        class TranslationComponent extends React.Component {
            render() {
                const strings = languages[this.props.currentLanguage][key];
                const merged = {
                    ...this.props.strings,
                    ...strings
                };
                if (strings) {
                    return (
                        <Component {...this.props}
                          strings={merged}
                          currentLanguage={this.props.currentLanguage}
                        />
                    );
                }

                return (
                    <Component {...this.props}
                      currentLanguage={this.props.currentLanguage}
                    />
                );
            }
        }
{'fraction_non_alphanumeric': 0.12331536388140162, 'fraction_numerical': 0.0, 'mean_word_length': 1.358220810166799, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4082396', 'n_tokens_mistral': 766, 'n_tokens_neox': 727, 'n_words': 210}