ter-localization-cli
Version:
Quick and powerful library for localization for react / react native application
2 lines • 16.5 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{127:function(e,t,n){e.exports=n(181)},132:function(e,t,n){},134:function(e,t,n){},178:function(e,t,n){},181:function(e,t,n){"use strict";n.r(t);var a=n(1),r=n.n(a),l=n(9),o=n.n(l),i=(n(132),n(11)),c=n(12),u=n(15),s=n(13),p=n(14),d=n(243),f=n(248),h=n(182),m=(n(134),n(6)),g=function(e){function t(){return Object(i.a)(this,t),Object(u.a)(this,Object(s.a)(t).apply(this,arguments))}return Object(p.a)(t,e),Object(c.a)(t,[{key:"render",value:function(){return r.a.createElement("div",{className:"app flex-row align-items-center"},r.a.createElement(m.g,null,r.a.createElement(m.l,{className:"justify-content-center"},r.a.createElement(m.f,{md:"6"},r.a.createElement("span",{className:"clearfix"},r.a.createElement("h1",{className:"float-left display-3 mr-4"},"TER"),r.a.createElement("h4",{className:"pt-3"},"ThreeEyedRaven's Localization"),r.a.createElement("p",{className:"text-muted float-left"},"Localization nightmare no more"))))))}}]),t}(a.Component),v=n(42),y=n(21),b=n(22),E=n.n(b),j=n(39),k=n(40),O=n(52),_={elements:[{type:"input",input_key:"storage_path",title:"Storage path",placeholder:"Default: localization"},{type:"input",input_key:"host",title:"Host",placeholder:"Default: localhost"},{type:"input",input_key:"port",title:"Port",placeholder:"Default: 5050"},{type:"input",input_key:"languages",title:"Languages",placeholder:"Comma separated, default: en,fr,jp"},{type:"input",input_key:"spreadsheet_id",title:"Spreadsheet Id",placeholder:"Spreadsheet id (document id of g-drive)"},{type:"input",input_key:"sheet_id",title:"Sheet Name",placeholder:"Sheet name, default null"}]},C=n(41),w=n(35),x=function(e){function t(e,n){var a;return Object(i.a)(this,t),(a=Object(u.a)(this,Object(s.a)(t).call(this,e,n))).state={data:{storage_path:"src/localization",host:"localhost",port:"5050",languages:"en,fr,jp",spreadsheet_id:"",sheet_id:""}},a.didPressDone=a.didPressDone.bind(Object(k.a)(a)),a}return Object(p.a)(t,e),Object(c.a)(t,[{key:"didPressDone",value:function(){var e=Object(j.a)(E.a.mark(function e(){var t,n,a,r,l,o,i,c;return E.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.state.data,n=t.storage_path,a=t.host,r=t.port,l=t.languages,o=t.spreadsheet_id,i=t.sheet_id,e.next=3,C.a.config.post({storage_path:n,host:a,port:r,languages:l,spreadsheet_id:o,sheet_id:i});case 3:if(c=e.sent,200!==c.data.code){e.next=8;break}return e.next=8,w.a.download();case 8:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"render",value:function(){var e=this,t=this.state.data;return r.a.createElement("div",{className:"app flex-row align-items-center"},r.a.createElement(m.g,null,r.a.createElement(m.l,{className:"justify-content-center"},r.a.createElement(m.f,{md:"9",lg:"7",xl:"6"},r.a.createElement(m.b,{className:"mx-4"},r.a.createElement(m.c,{className:"p-4"},r.a.createElement("h1",null,"Getting started"),r.a.createElement("p",{className:"text-muted"},"Setup for new project"),r.a.createElement(O.a,{template:_,value:t,onChange:function(t){var n=t.key,a=t.value;e.setState(function(e){return Object(y.a)({},e,{data:Object(y.a)({},e.data,Object(v.a)({},n,a))})})}}),r.a.createElement(m.a,{color:"success",block:!0,onClick:this.didPressDone},"Done. Set it up!")),r.a.createElement(m.d,{className:"p-4"},r.a.createElement("p",{className:"text-muted"},"or just give it a fuck and click here"),r.a.createElement(m.a,{color:"primary",block:!0,onClick:this.didPressDone},"I don't care, just continue")))))))}}]),t}(a.Component),S=function(e){function t(){return Object(i.a)(this,t),Object(u.a)(this,Object(s.a)(t).apply(this,arguments))}return Object(p.a)(t,e),Object(c.a)(t,[{key:"componentDidMount",value:function(){setTimeout(function(){w.a.download()},3e3)}},{key:"render",value:function(){var e=this.props.config;return r.a.createElement(d.a,null,r.a.createElement(f.a,null,!e&&r.a.createElement(h.a,{path:"/",name:"Welcome",component:g}),e&&!e.storage_path&&r.a.createElement(h.a,{path:"/",name:"Config",component:x}),e&&e.storage_path&&r.a.createElement(h.a,{path:"/",name:"Localization",component:O.b})))}}]),t}(a.Component),V=Object(O.c)(S);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(V,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})},35:function(e,t,n){"use strict";var a=n(22),r=n.n(a),l=n(39),o=n(41),i=[],c=null,u={getConfig:function(){return c},addListener:function(e){i.every(function(t){return t!==e})&&i.push(e)},removeListener:function(e){i=i.filter(function(t){return t!==e})},download:function(){var e=Object(l.a)(r.a.mark(function e(){var t,n;return r.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.a.config.get();case 2:t=e.sent,n=t.data,c=n,i.forEach(function(e){return e(c)});case 5:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}()};t.a=u},41:function(e,t,n){"use strict";var a=n(30),r=n.n(a),l={config:{get:function(){return r.a.get("/api/config")},post:function(e){var t=e.storage_path,n=e.host,a=e.port,l=e.languages,o=e.spreadsheet_id,i=e.sheet_id;return r.a.post("/api/config",{storage_path:t,host:n,port:a,languages:l,spreadsheet_id:o,sheet_id:i})}},word:{get:function(){return r.a.get("/api/word")}},sync:{getAuthorizationUrl:function(){return r.a.get("/api/sync/authorization_url")},upload:function(){return r.a.post("/api/sync/upload")},download:function(){return r.a.post("/api/sync/download")}}};t.a=l},52:function(e,t,n){"use strict";var a=n(11),r=n(12),l=n(15),o=n(13),i=n(14),c=n(1),u=n.n(c),s=n(248),p=n(182),d=n(245),f=n(6),h=n(28),m={items:[{title:!0,name:"Main"},{name:"Translation",url:"/translation",icon:"fa fa-language"},{title:!0,name:"Tools"},{name:"Sync",url:"/sync",icon:"fa fa-exchange"},{name:"Setting",url:"/setting",icon:"fa fa-cogs"}]},g=[{path:"/",exact:!0,name:"Home"},{path:"/translation",name:"Translation",component:u.a.lazy(function(){return Promise.all([n.e(7),n.e(3)]).then(n.bind(null,244))})},{path:"/setting",name:"Setting",component:u.a.lazy(function(){return n.e(4).then(n.bind(null,247))})},{path:"/sync",name:"Sync",component:u.a.lazy(function(){return n.e(5).then(n.bind(null,246))})}],v=u.a.lazy(function(){return n.e(1).then(n.bind(null,241))}),y=u.a.lazy(function(){return n.e(2).then(n.bind(null,242))}),b=function(e){function t(){var e,n;Object(a.a)(this,t);for(var r=arguments.length,i=new Array(r),c=0;c<r;c++)i[c]=arguments[c];return(n=Object(l.a)(this,(e=Object(o.a)(t)).call.apply(e,[this].concat(i)))).loading=function(){return u.a.createElement("div",{className:"animated fadeIn pt-1 text-center"},"Loading...")},n}return Object(i.a)(t,e),Object(r.a)(t,[{key:"signOut",value:function(e){e.preventDefault(),this.props.history.push("/login")}},{key:"render",value:function(){var e=this;return u.a.createElement("div",{className:"app"},u.a.createElement(h.c,{fixed:!0},u.a.createElement(c.Suspense,{fallback:this.loading()},u.a.createElement(y,{onLogout:function(t){return e.signOut(t)}}))),u.a.createElement("div",{className:"app-body"},u.a.createElement(h.e,{fixed:!0,display:"lg"},u.a.createElement(h.h,null),u.a.createElement(h.g,null),u.a.createElement(c.Suspense,null,u.a.createElement(h.j,Object.assign({navConfig:m},this.props))),u.a.createElement(h.f,null),u.a.createElement(h.i,null)),u.a.createElement("main",{className:"main"},u.a.createElement(h.a,{appRoutes:g}),u.a.createElement(f.g,{fluid:!0},u.a.createElement(c.Suspense,{fallback:this.loading()},u.a.createElement(s.a,null,g.map(function(e,t){return e.component?u.a.createElement(p.a,{key:t,path:e.path,exact:e.exact,name:e.name,render:function(t){return u.a.createElement(e.component,t)}}):null}),u.a.createElement(d.a,{from:"/",to:"/translation"})))))),u.a.createElement(h.b,null,u.a.createElement(c.Suspense,{fallback:this.loading()},u.a.createElement(v,null))))}}]),t}(c.Component),E=n(40),j=n(35),k=function(e){return function(t){function n(e,t){var r;return Object(a.a)(this,n),(r=Object(l.a)(this,Object(o.a)(n).call(this,e,t))).handleChange=r.handleChange.bind(Object(E.a)(r)),r}return Object(i.a)(n,t),Object(r.a)(n,[{key:"componentDidMount",value:function(){this._ismounted=!0,j.a.addListener(this.handleChange)}},{key:"componentWillUnmount",value:function(){this._ismounted=!1,j.a.removeListener(this.handleChange)}},{key:"handleChange",value:function(){this._ismounted&&this.forceUpdate()}},{key:"render",value:function(){return u.a.createElement(e,Object.assign({},this.props,{config:j.a.getConfig()}),this.props.children)}}]),n}(u.a.Component)},O=n(42),_=n(21),C=n(47),w=function(e){function t(e,n){var r;return Object(a.a)(this,t),(r=Object(l.a)(this,Object(o.a)(t).call(this,e,n))).state={edited:!1},r}return Object(i.a)(t,e),Object(r.a)(t,[{key:"onChangeText",value:function(e){var t=this.props.onChange;this.setState({edited:!0}),t&&(0===e.trim().length?t(null):t(e))}},{key:"render",value:function(){var e=this,t=this.props,n=t.title,a=t.validationResult,r=t.forceValidate,l=t.left_col,o=t.right_col,i=t.title_right,c=t.input_key,s=t.input_log,p=Object(C.a)(t,["title","validationResult","forceValidate","left_col","right_col","title_right","input_key","input_log"]),d=this.state.edited;return u.a.createElement(f.h,{row:!0},n&&u.a.createElement(f.f,{md:l,style:{display:"flex",alignItems:"center",fontWeight:"bold"}},u.a.createElement(f.j,{htmlFor:"name"},n)),u.a.createElement(f.f,{md:n?o:12,lg:s},u.a.createElement(f.i,Object.assign({className:"form-control"},p,{onChange:function(t){return e.onChangeText(t.nativeEvent.target.value)}})),u.a.createElement(x,{validationResult:a,inputKey:c,edited:d,forceValidate:r})),u.a.createElement(f.f,{md:2,style:{display:"flex",alignItems:"center",fontWeight:"bold"}},i&&u.a.createElement(f.j,{style:{fontWeight:"bold",width:30},htmlFor:"name"},i)))}}]),t}(c.Component),x=function(e){var t=e.validationResult,n=e.inputKey,a=e.edited,r=e.forceValidate;return(a||r)&&t&&t.fields&&t.fields[n]?t.fields[n].map(function(e){return u.a.createElement("p",{style:{color:"red",marginBottom:0}},e)}):null},S=w;w.defaultProps={t:null,onChange:null,type:null,title:null,left_col:4,right_col:8,input_key:null,validationResult:null,forceValidate:!1};var V=n(22),D=n.n(V),N=n(39),R=n(126),P=n(41),M={control:function(e){return Object(_.a)({},e,{borderColor:"#E3E7EA"})}},T=function(e){function t(e,n){var r;Object(a.a)(this,t),r=Object(l.a)(this,Object(o.a)(t).call(this,e,n));var i=e.mapPropsToState;return r.state={selectedValue:void 0,options:[],params:i?i(e):void 0,optionsCategory:[]},r}return Object(i.a)(t,e),Object(r.a)(t,[{key:"componentDidMount",value:function(){var e=Object(N.a)(D.a.mark(function e(){var t,n,a,r,l,o;return D.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.props,n=t.request,a=t.formValue,r=Object(C.a)(t,["request","formValue"]),e.next=3,P.a.categories.get();case 3:if(l=e.sent,!n){e.next=9;break}return e.next=7,n(Object(_.a)({},r,{formValue:a}));case 7:o=e.sent,this.setState(function(e){return Object(_.a)({},e,{options:o,optionsCategory:l.data.items||[]})});case 9:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"componentWillReceiveProps",value:function(){var e=Object(N.a)(D.a.mark(function e(t){var n,a,r,l,o;return D.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.mapPropsToState,a=t.request,r=this.state.params,!n||!a){e.next=9;break}if((l=n(t))===r){e.next=9;break}return e.next=7,a(t);case 7:o=e.sent,this.setState(function(e){return Object(_.a)({},e,{options:o,params:l})});case 9:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"onChangeText",value:function(e){var t=this.props.onChange;t&&t(e),this.setState({selectedValue:e})}},{key:"render",value:function(){var e=this,t=this.props,n=t.title,a=t.leftCol,r=t.rightCol,l=this.props,o=l.formValue,i=o.unit,c=o.category_id,s=l.input_key,p=this.state,d=p.options,h=p.optionsCategory,m={};switch(s){case"unit":m={label:i,value:i};break;case"category_id":var g=h.filter(function(e){return e.id===c}),v=g&&g[0]&&g[0].name;m={value:v,label:v}}return u.a.createElement(f.h,{row:!0},u.a.createElement(f.f,{md:a,style:{display:"flex",alignItems:"center",fontWeight:"bold"}},u.a.createElement(f.j,{style:{fontWeight:"bold"},htmlFor:"name"},n)),u.a.createElement(f.f,{md:r},u.a.createElement(R.a,{styles:M,options:d,onChange:function(t){return e.onChangeText(t.value)},value:m})))}}]),t}(c.Component),Y=T;T.defaultProps={title:"",leftCol:4,rightCol:8,request:!1,mapPropsToState:null,onChange:null,formValue:null};var W=n(108),z=(n(178),n(80)),L=n.n(z),I=function(e){function t(e,n){var r;return Object(a.a)(this,t),(r=Object(l.a)(this,Object(o.a)(t).call(this,e,n))).state={edited:!1},r}return Object(i.a)(t,e),Object(r.a)(t,[{key:"onChangeText",value:function(e){var t=this.props.onChange;if(this.setState({edited:!0}),t)if(void 0===e||null===e)t("");else if(0!==e.length){var n=L()(e,"YYYY-MM-DD",!0).isValid(),a=L()(e,"YYYY").year()<1e4;t(n&&a?L()(e).format("YYYY-MM-DD"):new Date)}}},{key:"render",value:function(){var e=this,t=this.props,n=t.title,a=t.validationResult,r=t.forceValidate,l=t.left_col,o=t.right_col,i=t.input_key,c=t.value,s=Object(C.a)(t,["title","validationResult","forceValidate","left_col","right_col","input_key","value"]),p=this.state.edited;return u.a.createElement(f.h,{row:!0},u.a.createElement(f.f,{md:l,style:{display:"flex",alignItems:"center"}},u.a.createElement(f.j,{style:{fontWeight:"bold"},htmlFor:"name"},n)),u.a.createElement(f.f,{md:o},u.a.createElement("div",{style:{flexDirection:"row",display:"flex"}},u.a.createElement(W.a,Object.assign({className:"form-control"},s,{selected:c,onChange:function(t){return e.onChangeText(t)},showYearDropdown:!0,showMonthDropdown:!0,dateFormatCalendar:"MMMM",scrollableYearDropdown:!0,dateFormat:"yyyy-MM-dd",ref:function(t){e.calendar=t}})),u.a.createElement("button",{style:{width:20,height:20,position:"absolute",top:7,right:23,outline:0,borderWidth:0,backgroundColor:"transparent"},onClick:function(){return e.calendar.setFocus()},type:"button",alt:"calendar"},u.a.createElement("img",{style:{width:20,height:20,position:"absolute",top:0,right:0},alt:"true"}))),u.a.createElement(F,{validationResult:a,inputKey:i,edited:p,forceValidate:r})))}}]),t}(c.Component),F=function(e){var t=e.validationResult,n=e.inputKey,a=e.edited,r=e.forceValidate;return(a||r)&&t&&t.fields&&t.fields[n]?t.fields[n].map(function(e){return u.a.createElement("p",{style:{color:"red",marginBottom:0}},e)}):null},q=I;I.defaultProps={t:null,onChange:null,type:null,title:null,left_col:4,right_col:8,value:null,input_key:null,validationResult:null,forceValidate:!1};var B=function(e){function t(e,n){var r;return Object(a.a)(this,t),(r=Object(l.a)(this,Object(o.a)(t).call(this,e,n))).state={value:e.value},r}return Object(i.a)(t,e),Object(r.a)(t,[{key:"componentWillReceiveProps",value:function(e){this.setState(function(t){return Object(_.a)({},t,{value:Object(_.a)({},t.value,e.value)})})}},{key:"onChange",value:function(e,t){if(e){this.setState(function(n){return{value:Object(_.a)({},n.value,Object(O.a)({},e,t))}});var n=this.props.onChange;n&&n({key:e,value:t})}}},{key:"render",value:function(){var e=this,t=this.props,n=t.template.elements,a=t.validationResult,r=t.forceValidate,l=this.state.value;return u.a.createElement(f.l,null,n.map(function(t){switch(t.type){case"select":return u.a.createElement(f.f,{xs:t.col||12},u.a.createElement(Y,Object.assign({},t,{key:t.input_key,value:l[t.input_key],formValue:l,onChange:function(n){return e.onChange(t.input_key,n)}})));case"datepicker":return u.a.createElement(f.f,{xs:t.col||12},u.a.createElement(q,Object.assign({},t,{key:t.input_key,value:l[t.input_key],formValue:l,onChange:function(n){return e.onChange(t.input_key,n)}})));default:return u.a.createElement(f.f,{xs:t.col||12},u.a.createElement(S,Object.assign({},t,{title:t.title?t.title:"",key:t.input_key,value:l[t.input_key],onChange:function(n){return e.onChange(t.input_key,n)},validationResult:a,forceValidate:r})))}}))}}]),t}(c.Component),K=B;B.defaultProps={onChange:null,value:null,template:null,validationResult:null,forceValidate:!1},n.d(t,"b",function(){return b}),n.d(t,"c",function(){return k}),n.d(t,"a",function(){return K})}},[[127,8,6]]]);
//# sourceMappingURL=main.810bdb5a.chunk.js.map