class Lang extends React.Component { constructor(props) { super(props); this.state = { lan: "English", lanlogo: "language", showimg: "1", }; } componentWillMount() { if (this.props.lan === "kr") { this.setState({ lan: "한국인", }) this.setState({ lanlogo: "언어" }) this.setState({ showimg: "2" }) } if (this.props.lan === "vn") { this.setState({ lan: "Việt Nam", }) this.setState({ lanlogo: "ngôn ngữ" }) this.setState({ showimg: "3" }) } if (this.props.lan === "ru") { this.setState({ lan: "Русский", }) this.setState({ lanlogo: "язык" }) this.setState({ showimg: "4" }) } if (this.props.lan === "id") { this.setState({ lan: "Indonesia", }) this.setState({ lanlogo: "bahasa" }) this.setState({ showimg: "5" }) } if (this.props.lan === "in") { this.setState({ lan: "इंडी", }) this.setState({ lanlogo: "भाषा:हिन्दी" }) this.setState({ showimg: "6" }) } if (this.props.lan === "bd") { this.setState({ lan: "বাংলা", }) this.setState({ lanlogo: "ভাষা" }) this.setState({ showimg: "7" }) } if (this.props.lan === "my") { this.setState({ lan: "Melayu", }) this.setState({ lanlogo: "Bahasa" }) this.setState({ showimg: "8" }) } if (this.props.lan === "ar") { this.setState({ lan: "عرب", }) this.setState({ lanlogo: "لغة" }) this.setState({ showimg: "9" }) } if (this.props.lan === "hk") { this.setState({ lan: "繁體中文", }) this.setState({ lanlogo: "語言" }) this.setState({ showimg: "10" }) } if (this.props.lan === "pt") { this.setState({ lan: "Portugal", }) this.setState({ lanlogo: "Língua" }) this.setState({ showimg: "11" }) } if (this.props.lan === "tr") { this.setState({ lan: "Türk", }) this.setState({ lanlogo: "Dil" }) this.setState({ showimg: "12" }) } } chooselang(param, event) { var str = location.pathname; if (this.props.lan !== "index") { str = str.substring(3) console.log(str); } if (param === 1) { location.href = str } if (param === 2) { location.href = "/kr" + str } if (param === 3) { location.href = "/vn" + str } if (param === 4) { location.href = "/ru" + str } if (param === 5) { location.href = "/id" + str } if (param === 6) { location.href = "/in" + str } if (param === 7) { location.href = "/bd" + str } if (param === 8) { location.href = "/my" + str } if (param === 9) { location.href = "/ar" + str } if (param === 10) { location.href = "/hk" + str } if (param === 11) { location.href = "/pt" + str } if (param === 12) { location.href = "/tr" + str } } render() { return (
{this.state.lanlogo} {this.state.lan}
); } }