Skip to content

Commit

Permalink
feature:#194/학식 영어로 받아오기 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmj12 committed May 12, 2024
1 parent ec51a63 commit 95fafb1
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 238 deletions.
9 changes: 9 additions & 0 deletions front/capstone_front/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@
"chatbotScreen": {
"chatbot": "Chat Bot",
"textfield_hint": "Please enter your questions"
},
"weekday": {
"mon": "MON",
"tue": "TUE",
"wed": "WED",
"thu": "THU",
"fri": "FRI",
"sat": "SAT",
"sun": "SUN"
}
}
16 changes: 15 additions & 1 deletion front/capstone_front/assets/translations/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"notice": "공지사항",
"cafeteria": "학식정보",
"school_info": "학교정보",
"other_info": "기타정보",
"shcool_map": "학교지도",
"facility_info": "시설정보",
"shuttle_info": "셔틀정보",
"qna": "질문과 답변",
"faq": "자주 묻는 질문",
"community": "커뮤니티",
Expand All @@ -55,11 +59,21 @@
"no": "아니요",
"account_setting": "계정 설정",
"logout": "로그아웃",
"no_data": "데이터가 없습니다"
"no_data": "데이터가 없습니다",
"use_chatbot": "챗봇 사용하기"
},
"cafeteria": {
"no_data": "미운영중입니다"
},
"weekday": {
"mon": "",
"tue": "",
"wed": "",
"thu": "",
"fri": "",
"sat": "",
"sun": ""
},
"speech": {
"speech_practice": "발음 연습",
"example_sentence": "예문",
Expand Down
2 changes: 1 addition & 1 deletion front/capstone_front/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:capstone_front/firebase_options.dart';
import 'package:capstone_front/models/chat_init_model.dart';
import 'package:capstone_front/models/cafeteria_menu_model_ko.dart';
import 'package:capstone_front/models/cafeteria_menu_model.dart';
import 'package:capstone_front/models/helper_article_preview_model.dart';
import 'package:capstone_front/models/notice_model.dart';
import 'package:capstone_front/models/qna_post_model.dart';
Expand Down
183 changes: 183 additions & 0 deletions front/capstone_front/lib/models/cafeteria_menu_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
class CafeteriaMenuModel {
List<List<List<String>>> cafeteriaMenus = [];
List<String> cafeteriaKo = [
"한울식당(법학관 지하1층)",
"학생식당(복지관 1층)",
"교직원식당(복지관 1층)",
"청향 한식당(법학관 5층)",
"청향 양식당(법학관 5층)",
"생활관식당 일반식(생활관 A동 1층)",
"생활관식당 정기식(생활관 A동 1층)",
];
List<String> cafeteriaEn = [
"Hanwool Restaurant (B1F, Law Building)",
"Student Center (Welfare Center 1F)",
"Faculty and Staff Cafeteria (Welfare Center, 1st floor)",
"Cheonghyang Korean Restaurant (5th floor, Law Building)",
"Cheonghyang Form Hall (5th floor of the Law Building)",
"Dormitory Cafeteria (Dormitory A, 1st floor)",
"Dormitory Cafeteria (Dormitory Building A, 1st floor)",
];

void addFunc(
var data, List<List<String>> targetList, String type, String addName) {
if (data != null && data[type] != null) {
String tmpMenu = data[type]["메뉴"];
// menu
tmpMenu = tmpMenu.replaceAll('\r\n', ' ');
// ※가 2번 나오면 줄바꿈
int tmp1 = 0;
// []가 2번 이상 나오면 줄바꿈
int tmp2 = 0;
for (int i = 0; i < tmpMenu.length; i++) {
if (tmpMenu[i] == '※') {
tmp1 += 1;
if (tmp1 == 1) {
tmpMenu =
'${tmpMenu.substring(0, i + 1)} ${tmpMenu.substring(i + 1)}';
}
} else if (tmpMenu[i] == '[') {
tmp2 += 1;
if (tmp2 >= 2) {
tmpMenu = '${tmpMenu.substring(0, i)}\n${tmpMenu.substring(i)}';
i += 2;
}
} else if (tmpMenu[i] == 'ï') {
tmpMenu = '${tmpMenu.substring(0, i)}${tmpMenu.substring(i + 3)}';
i += 2;
}
if (tmp1 == 2) {
tmp1 = 0;
tmpMenu =
'${tmpMenu.substring(0, i + 1)}\n${tmpMenu.substring(i + 2)}';
}
}
targetList.add([addName, tmpMenu, data[type]["가격"]]);
}
}

void addDataKo(int cafeteriaIndex, var data) {
List<List<String>> tmpList = [];
if (cafeteriaIndex == 0) {
addFunc(data, tmpList, "1코너<br>SNACK1", "1코너 SNACK1");
addFunc(data, tmpList, "1코너<br>SNACK2", "1코너 SNACK2");
addFunc(data, tmpList, "2코너<BR>NOODLE", "2코너 NOODLE");
addFunc(data, tmpList, "3코너<br>CUTLET", "3코너 CUTLET");
addFunc(data, tmpList, "4코너<br>RICE.Oven", "4코너 RICE.Oven");
addFunc(data, tmpList, "5코너<br>GUKBAP.Chef", "5코너 GUKBAP.Chef");
} else if (cafeteriaIndex == 1) {
addFunc(data, tmpList, "착한아침", "착한아침");
addFunc(data, tmpList, "천원의 아침밥", "천원의 아침밥");
addFunc(data, tmpList, "가마<br>중식", "가마 중식");
addFunc(data, tmpList, "데일리밥<br>중식", "데일리밥 중식");
addFunc(data, tmpList, "채식<br>중식", "채식 중식");
addFunc(data, tmpList, "인터쉐프<br>중식", "인터쉐프 중식");
addFunc(data, tmpList, "누들송<br>중식", "누들송 중식");
addFunc(data, tmpList, "석식Ⅰ", "석식Ⅰ");
addFunc(data, tmpList, "석식Ⅱ", "석식Ⅱ");
} else if (cafeteriaIndex == 2) {
addFunc(data, tmpList, "키친1", "키친1");
addFunc(data, tmpList, "키친2", "키친2");
addFunc(data, tmpList, "오늘의<br>샐러드", "오늘의 샐러드");
addFunc(data, tmpList, "석식", "석식");
} else if (cafeteriaIndex == 3) {
addFunc(data, tmpList, "메뉴1", "메뉴1");
addFunc(data, tmpList, "메뉴2", "메뉴2");
addFunc(data, tmpList, "메뉴3", "메뉴3");
addFunc(data, tmpList, "메뉴4", "메뉴4");
} else if (cafeteriaIndex == 4) {
addFunc(data, tmpList, "파스타", "PASTA");
addFunc(data, tmpList, "리조또", "RISOTTO");
addFunc(data, tmpList, "STEAK", "STEAK");
} else if (cafeteriaIndex == 5) {
addFunc(data, tmpList, "중식", "중식");
} else if (cafeteriaIndex == 6) {
if (data != null && data["석식"] != null) {
tmpList.add(["석식", data["석식"]["메뉴"], "정기식 신청자 한정"]);
}
}
cafeteriaMenus.add(tmpList);
}

void addDataEn(int cafeteriaIndex, var data) {
List<List<String>> tmpList = [];
if (cafeteriaIndex == 0) {
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK1", "Corner1 SNACK1");
addFunc(data, tmpList, "1Corner\u003Cbr\u003ESNACK2", "Corner1 SNACK2");
addFunc(data, tmpList, "2Corner\u003CBR\u003ENOODLE", "Corner2 NOODLE");
addFunc(data, tmpList, "3Corner\u003Cbr\u003ECUTLET", "Corner3 CUTLET");
addFunc(
data, tmpList, "4Corner\u003Cbr\u003ERICE.Oven", "Corner4 RICE.Oven");
addFunc(data, tmpList, "5Corner\u003Cbr\u003EGUKBAP.Chef",
"Corner5 GUKBAP.Chef");
} else if (cafeteriaIndex == 1) {
addFunc(data, tmpList, "Good Morning", "Good Morning");
addFunc(data, tmpList, "Breakfast for a Thousand",
"Breakfast for a Thousand");
addFunc(data, tmpList, "Kiln\u003Cbr\u003ELunch", "Kama lunch");
addFunc(
data, tmpList, "Daily Meals\u003Cbr\u003ELunch", "DailyBop Lunch");
addFunc(
data, tmpList, "Vegetarian\u003Cbr\u003EMedium", "Vegiterian Lunch");
addFunc(data, tmpList, "InterChef\u003Cbr\u003ELunch", "InterChef Lunch");
addFunc(
data, tmpList, "Noodlesong\u003Cbr\u003ELunch", "NoodleSong Lunch");
addFunc(data, tmpList, "Dinner I", "Dinner Ⅰ");
addFunc(data, tmpList, "Dinner II", "Dinner Ⅱ");
} else if (cafeteriaIndex == 2) {
addFunc(data, tmpList, "Kitchen1", "Kitchen1");
addFunc(data, tmpList, "Kitchen2", "Kitchen2");
addFunc(data, tmpList, "Today's\u003Cbr\u003ESalad", "Today's Salad");
addFunc(data, tmpList, "Dinner", "Dinner");
} else if (cafeteriaIndex == 3) {
addFunc(data, tmpList, "Menu1", "Menu1");
addFunc(data, tmpList, "Menu2", "Menu2");
addFunc(data, tmpList, "Menu3", "Menu3");
addFunc(data, tmpList, "Menu4", "Menu4");
} else if (cafeteriaIndex == 4) {
addFunc(data, tmpList, "PASTA", "PASTA");
addFunc(data, tmpList, "RICE", "RISOTTO");
addFunc(data, tmpList, "STEAK", "STEAK");
} else if (cafeteriaIndex == 5) {
addFunc(data, tmpList, "Lunch", "Lunch");
} else if (cafeteriaIndex == 6) {
if (data != null && data["Dinner"] != null) {
tmpList.add(["Dinner", data["Dinner"]["메뉴"], "Applicants only"]);
}
}
cafeteriaMenus.add(tmpList);
}

CafeteriaMenuModel.fromJson(
List<dynamic> json, String date, String language) {
if (language == 'KO') {
for (int i = 0; i < cafeteriaKo.length; i++) {
bool dataAdded = false;
for (int j = 0; j < json.length; j++) {
if (json[j][cafeteriaKo[i]] != null) {
addDataKo(i, json[j][cafeteriaKo[i]][date]);
dataAdded = true;
break;
}
}
if (!dataAdded) {
cafeteriaMenus.add([]);
}
}
} else if (language == 'EN-US') {
for (int i = 0; i < cafeteriaEn.length; i++) {
bool dataAdded = false;
for (int j = 0; j < json.length; j++) {
if (json[j][cafeteriaEn[i]] != null) {
addDataEn(i, json[j][cafeteriaEn[i]][date]);
dataAdded = true;
break;
}
}
if (!dataAdded) {
cafeteriaMenus.add([]);
}
}
}
}
}
107 changes: 0 additions & 107 deletions front/capstone_front/lib/models/cafeteria_menu_model_en.dart

This file was deleted.

Loading

0 comments on commit 95fafb1

Please sign in to comment.