lan.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. //設定cookie
  2. function setCookie(name,value)
  3. {
  4. var Days = 30;
  5. var exp = new Date();
  6. exp.setTime(exp.getTime() + Days*24*60*60*1000);
  7. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  8. }
  9. //獲取cookie
  10. function getCookie(name)
  11. {
  12. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  13. if(arr=document.cookie.match(reg))
  14. return unescape(arr[2]);
  15. else
  16. return null;
  17. }
  18. // 讀取語系設定
  19. let lang = localStorage.getItem('lan');
  20. console.log('目前語系設定: ' + lang); // test
  21. if(lang == null) {
  22. console.log('未設定語系'); // test
  23. // 自動設定語系
  24. var userlang = window.navigator.userLanguage || window.navigator.language;
  25. userlang = userlang.toLowerCase();
  26. console.log('userlang: ' + userlang); // test
  27. if (userlang == 'zh-tw') {
  28. console.log('自動設定語系: 繁體中文');
  29. lang = 'zh';
  30. } else if (userlang == 'en-us') {
  31. console.log('自動設定語系: 英文');
  32. lang = 'en';
  33. } else if (userlang == 'zh-cn') {
  34. console.log('自動設定語系: 繁體中文');
  35. lang = 'zh';
  36. } else {
  37. console.log('自動設定語系: 繁體中文');
  38. lang = 'zh';
  39. }
  40. }
  41. var zh = {
  42. "logleftbox1": "將你的生活、創作 、宣傳做成影片",
  43. "logleftbox2": "開始使用 AI Spokesgirl",
  44. "make_video" : "影片製作",
  45. "make_slides" : "投影影片製作",
  46. "make_video_long": "長影片製作",
  47. "make_video_eng": "純英文影片製作",
  48. "login" : "登入",
  49. "login_link" : "立即登入",
  50. "user_profile": "會員資料",
  51. "logout": "登出",
  52. "logout-m": "<i class='fas fa-sign-out-alt text-white me-3'></i>登&emsp;&ensp;出",
  53. "en": "English",
  54. "zh": "中文",
  55. "choose_character": "選擇人物",
  56. "usage_intro": "使用說明",
  57. "history": "歷史紀錄",
  58. "preview_videos": "預覽影片",
  59. "video_link": "影片連結",
  60. "video_title": "標題",
  61. "p_choose_character": "請選擇人物",
  62. "lines": "台詞",
  63. "img_link": "影像連結",
  64. "processing_progress": "處理進度",
  65. "usage_intro": "使用說明",
  66. "one_line_to_one_img": "1. 一句台詞請對應提供一個影像連結做為搭配",
  67. "sup_img_profile": "2. 影像連結檔案格式支援:",
  68. "submit_to_wait": "3. 點選“送出”之後需等待一段影片製作的時間,請您耐心等候,待製作完畢可於通知網址查看",
  69. "add_eng": "加入英文:",
  70. "submit": "送出",
  71. "privacy_term": "同意隱私政策及使用條款",
  72. "newHere": "還沒有帳號?",
  73. "oldHere": "已經有帳號?",
  74. "goRegister": "註冊",
  75. "goRegister_link": "立即註冊",
  76. "pricing" : "早鳥方案",
  77. "pricing-m" : "<i class='fas fa-tags me-2'></i>&ensp;早鳥方案",
  78. "errorEmail": "請輸入正確E-mail",
  79. "errorPsd": "密碼至少為4個字元",
  80. "used": "已使用",
  81. "left": "未使用",
  82. "sec": "秒",
  83. "username": "帳號/用戶名稱",
  84. "password": "密碼",
  85. "resetPsd": "更改密碼",
  86. "forgotPsd": "忘記密碼",
  87. "details": "查看詳情",
  88. "refill": "我要加值",
  89. "Createsthtoday": "今天要做甚麼影片呢?",
  90. "date": "日期",
  91. "video_duration": "影片時間",
  92. "slide_link": "SLIDE 連結",
  93. "new_pwd": "新密碼",
  94. "confirm_pwd": "驗證碼",
  95. "pricing_lan": "語言選擇: 中文 | 英文",
  96. "pricing_avatars": "多款預設AI代言主播任你選",
  97. "pricing_content": "畫面素材支援: 圖檔 | 影檔 | 簡報",
  98. "pricing_discount": "限時優惠",
  99. "pricing_checkout": "立即註冊",
  100. "mins": "分鐘",
  101. "launch_special": "早鳥方案",
  102. "index_li1_1": "支援中英文內容",
  103. "index_li1_2": "可加入字幕",
  104. "index_li2_1": "無人物肖像權問題",
  105. "index_li2_2": "人物表情、動作自然",
  106. "index_li2_3": "因應主題,選擇合適人物",
  107. "index_li3_1": "可上傳圖片或是影片作為背景",
  108. "index_li3_2": "可輸入文字腳本及投影片",
  109. "index_action": "想要快速製作影音內容?立即註冊,開始創作!",
  110. "follow_us": "關注我們",
  111. "contact_name": "集仕多股份有限公司",
  112. "address": "新竹縣竹北市復興二路229號9樓之9",
  113. "contact_tel": "聯絡電話",
  114. "contact_mail": "聯絡信箱",
  115. "draft_edit": "編輯",
  116. "drafts": "草稿夾",
  117. "save_draft_btn": "存為草稿",
  118. "upload_file": "上傳檔案",
  119. "intro_img": "static/img/intro2.jpg",
  120. "no_draft": "目前沒有草稿喔",
  121. "trial_title": "想要免費獲得更多時間額度?",
  122. "trial_txt": "透過社群分享專屬連結,邀請好友註冊 AI Spokesgirl,凡是好友透過連結註冊成功,您可以免費獲得2分鐘製作額度。",
  123. "share": "分享",
  124. "close": "關閉"
  125. };
  126. var en = {
  127. "logleftbox1": "Make your first video for promotion, creation and life today",
  128. "logleftbox2": "Let's get started with AI Spokesgirl",
  129. "make_video" : "Make Videos",
  130. "make_slides" : "Make Videos By Slides",
  131. "make_video_long": "Make Long Videos",
  132. "make_video_eng": "Make English Video",
  133. "login" : "Login",
  134. "login_link" : "Login",
  135. "user_profile": "User Profile",
  136. "logout": "Logout",
  137. "en": "English",
  138. "zh": "中文",
  139. "choose_character": "Choose Character",
  140. "usage_intro": "Usage Introduction",
  141. "history": "History",
  142. "preview_videos": "Preview Videos",
  143. "video_link": "Video Link",
  144. "video_title": "Video Title",
  145. "p_choose_character": "Choose Character",
  146. "lines": "Lines",
  147. "img_link": "Image Link",
  148. "processing_progress": "Processing Progress",
  149. "usage_intro": "Usage Introduction",
  150. "one_line_to_one_img": "1. Please Provide an Image Link Corresponding to a Line as a Collocation",
  151. "sup_img_profile": "2. Supported File Format:",
  152. "submit_to_wait": "3. After Clicking Submit, You Will Need To Wait For A Period Of Time For The Production Of The Video. Please Wait Patiently. You Can Check It At The Notification URL When The Production Is Completed.",
  153. "add_eng": "Allow English Lines:",
  154. "submit": "Submit",
  155. "privacy_term": "I Agree to privacy policy and terms of use.",
  156. "newHere": "New here?",
  157. "oldHere": "Already have an account?",
  158. "goRegister": "REGISTER",
  159. "goRegister_link": "REGISTER",
  160. "pricing" : "Pricing",
  161. "errorEmail": "Please enter valid Email format.",
  162. "errorPsd": "Passwords must be at least 4 characters long.",
  163. "used": "Already Used",
  164. "left": "Left",
  165. "sec": "Sec",
  166. "username": "User Name",
  167. "password": "Password",
  168. "resetPsd": "Reset Password",
  169. "forgotPsd": "Forgot Password",
  170. "details": "Details",
  171. "refill": "Refill",
  172. "Createsthtoday": "Create something today!",
  173. "date": "Date",
  174. "video_duration": "Duration",
  175. "slide_link": "SLIDE Link",
  176. "new_pwd": "New Password",
  177. "confirm_pwd": "Confirmation Code",
  178. "pricing_lan": "Language Options: Ch | Eng",
  179. "pricing_avatars": "Over 6 Avatars Available",
  180. "pricing_content": "You can upload: images, MP4, slides",
  181. "pricing_discount": "Special Discount",
  182. "pricing_checkout": "Check it out",
  183. "mins": "Minutes",
  184. "launch_special": "Launch special",
  185. "index_li1_1": "Support english & chinese content",
  186. "index_li1_2": "Caption included",
  187. "index_li2_1": "Free of portrait rights",
  188. "index_li2_2": "Natural facial expression",
  189. "index_li2_3": "Choose built-in avatars for your need",
  190. "index_li3_1": "Generate videos from text",
  191. "index_li3_2": "Upload images, video, slides as backgrounds",
  192. "index_action": "Want to make video faster? Sign up to start creating!",
  193. "follow_us": "Follow us",
  194. "contact_name": "Choozmo Inc.",
  195. "address": "Rm. 9, 9F., No. 229, Fuxing 2nd Rd., Zhubei City, Hsinchu County 302052, Taiwan (R.O.C.)",
  196. "contact_tel": "Tel",
  197. "contact_mail": "Email",
  198. "draft_edit": "Edit",
  199. "drafts": "Drafts",
  200. "save_draft_btn": "Save as Draft",
  201. "upload_file": "Upload",
  202. "intro_img": "static/img/intro_en.png",
  203. "no_draft": "No drafts yet.",
  204. "trial_title": "Want to get more minutes?",
  205. "trial_txt": "Invite your friends to AI Spokesgirl and for each eligible one that signs up from your referral, we'll give you 2 more minutes free!",
  206. "share": "Share:",
  207. "close": "Close"
  208. };
  209. function switchLanContent(val){
  210. $('[set-lan]').each(function(){
  211. var me = $(this);
  212. var a = me.attr('set-lan').split(':');
  213. var p = a[0]; //文字放置位置
  214. var m = a[1]; //文字標示
  215. //用虎選擇語言後保存在cookie中,這裡讀取cooikes的語言版本
  216. // var lan = getCookie('lan');
  217. // console.log(lan);
  218. //選取語言文字
  219. switch(val){
  220. case 'zh':
  221. var t = zh[m];
  222. break;
  223. case 'en':
  224. var t = en[m];
  225. break;
  226. default:
  227. var t = zh[m];
  228. }
  229. //所選語言沒有就換
  230. if(t==undefined) t = en[m];
  231. if(t==undefined) t = zh[m];
  232. if(t==undefined) return true; //都沒有就跳出
  233. //文字放置位置有(html,val等,可以自己添加)
  234. switch(p){
  235. case 'html':
  236. me.html(t);
  237. break;
  238. case 'placeholder':
  239. me.attr('placeholder', t);
  240. console.log("placeholder");
  241. case 'val':
  242. case 'value':
  243. me.val(t);
  244. break;
  245. case 'img':
  246. me.attr('src', t);
  247. break;
  248. default:
  249. me.html(t);
  250. }
  251. });
  252. }
  253. changeLang(lang);
  254. function changeLang(val) {
  255. localStorage.setItem('lan', `${val}`);
  256. // setCookie('lan', val);
  257. switchLanContent(val);
  258. }
  259. // 4. 轉換
  260. function changeLan(val) {
  261. var val = val.value;
  262. console.log(`val: ${val}`);
  263. localStorage.setItem('lan', `${val}`);
  264. // setCookie('lan', val);
  265. switchLanContent(val);
  266. }
  267. // js裡面的轉換
  268. function get_lan(m)
  269. {
  270. //獲取文字
  271. var lan = getCookie('lan'); //語言版本
  272. //選取語言文字
  273. switch(lan){
  274. case 'zh':
  275. var t = zh[m];
  276. break;
  277. case 'hk':
  278. var t = hk[m];
  279. break;
  280. default:
  281. var t = en[m];
  282. }
  283. //如果沒有找到就轉換其他語言
  284. if(t==undefined) t = zh[m];
  285. if(t==undefined) t = en[m];
  286. if(t==undefined) t = hk[m];
  287. if(t==undefined) t = m; //如果還是沒有就直接用標示
  288. return t;
  289. }