lan.js 9.5 KB

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