Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(language): đa ngôn ngữ #84

Merged
merged 15 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -41,6 +42,7 @@ import com.ramcosta.composedestinations.generated.destinations.StudySetDetailScr
import com.ramcosta.composedestinations.generated.destinations.UserDetailScreenDestination
import com.ramcosta.composedestinations.generated.destinations.UserDetailScreenDestination.invoke
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.pwhs.quickmem.R

@Composable
@Destination<RootGraph>
Expand Down Expand Up @@ -104,7 +106,6 @@ fun ExploreScreen(
onCreateStudySet = {
viewModel.onEvent(ExploreUiAction.OnCreateStudySet)
},
errorMessage = uiState.errorMessage
)
}

Expand All @@ -131,12 +132,11 @@ fun Explore(
onQuestionTypeChange: (QuestionType) -> Unit = {},
onDifficultyLevelChange: (DifficultyLevel) -> Unit = {},
onCreateStudySet: () -> Unit = {},
errorMessage: String = ""
) {
var tabIndex by remember { mutableIntStateOf(0) }
val tabTitles = listOf(
"Create Study Set AI",
"Top Streak",
stringResource(R.string.txt_create_study_set_ai),
stringResource(R.string.txt_top_streak),
)

Scaffold(
Expand All @@ -145,7 +145,7 @@ fun Explore(
CenterAlignedTopAppBar(
title = {
Text(
text = "Explore",
text = stringResource(R.string.txt_explore),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ fun CreateStudySetAITab(
) {
Icon(
painter = painterResource(R.drawable.ic_sparkling),
contentDescription = "Create",
contentDescription = stringResource(R.string.txt_create),
)
Text(
text = "Create",
text = stringResource(R.string.txt_create),
style = typography.bodyMedium.copy(
fontWeight = FontWeight.Bold
)
Expand All @@ -141,7 +141,7 @@ fun CreateStudySetAITab(
modifier = Modifier.padding(bottom = 8.dp)
) {
Text(
text = "Warning: AI may not generate accurate or complete flashcards. Please review if unsure.",
text = stringResource(R.string.txt_warning_ai_not_gen),
color = Color.Red,
style = typography.bodyMedium.copy(fontWeight = FontWeight.Bold),
textAlign = TextAlign.Start,
Expand Down Expand Up @@ -176,7 +176,7 @@ fun CreateStudySetAITab(
onValueChange = onTitleChange,
placeholder = {
Text(
text = "Title (required)",
text = stringResource(R.string.txt_title_required),
style = typography.bodyMedium,
)
}
Expand All @@ -194,7 +194,7 @@ fun CreateStudySetAITab(
onValueChange = onDescriptionChange,
placeholder = {
Text(
text = "Description (optional)",
text = stringResource(R.string.txt_description_optional),
style = typography.bodyMedium,
)
},
Expand All @@ -211,7 +211,7 @@ fun CreateStudySetAITab(
}
item {
Text(
text = "Number of flashcards (optional)",
text = stringResource(R.string.txt_number_of_flashcards_optional),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
Expand All @@ -232,7 +232,7 @@ fun CreateStudySetAITab(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text("5")
Text(stringResource(R.string.txt_number_of_flashcards_5))
RadioButton(
selected = numberOfFlashcards == 5,
onClick = { onNumberOfFlashcardsChange(5) }
Expand All @@ -246,7 +246,7 @@ fun CreateStudySetAITab(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text("10")
Text(stringResource(R.string.txt_number_of_flashcards_10))
RadioButton(
selected = numberOfFlashcards == 10,
onClick = { onNumberOfFlashcardsChange(10) }
Expand All @@ -260,7 +260,7 @@ fun CreateStudySetAITab(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text("15")
Text(stringResource(R.string.txt_number_of_flashcards_15))
RadioButton(
selected = numberOfFlashcards == 15,
onClick = { onNumberOfFlashcardsChange(15) }
Expand All @@ -274,7 +274,7 @@ fun CreateStudySetAITab(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text("20")
Text(stringResource(R.string.txt_number_of_flashcards_20))
RadioButton(
selected = numberOfFlashcards == 20,
onClick = { onNumberOfFlashcardsChange(20) }
Expand Down Expand Up @@ -310,7 +310,7 @@ fun CreateStudySetAITab(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "Language",
text = stringResource(R.string.txt_language),
style = typography.bodyMedium.copy(
fontWeight = FontWeight.Bold
)
Expand All @@ -336,7 +336,7 @@ fun CreateStudySetAITab(
}
item {
Text(
text = "Question type",
text = stringResource(R.string.txt_question_type),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
Expand All @@ -363,7 +363,7 @@ fun CreateStudySetAITab(
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(text = "Multiple choice")
Text(text = stringResource(R.string.txt_multiple_choice))
Spacer(modifier = Modifier.weight(1f))
RadioButton(
selected = questionType == QuestionType.MULTIPLE_CHOICE,
Expand All @@ -377,7 +377,7 @@ fun CreateStudySetAITab(
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(text = "True/False")
Text(text = stringResource(R.string.txt_true_false))
Spacer(modifier = Modifier.weight(1f))
RadioButton(
selected = questionType == QuestionType.TRUE_FALSE,
Expand All @@ -390,7 +390,7 @@ fun CreateStudySetAITab(

item {
Text(
text = "Difficulty level",
text = stringResource(R.string.txt_difficulty_level),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
Expand All @@ -416,7 +416,7 @@ fun CreateStudySetAITab(
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(text = "Easy")
Text(text = stringResource(R.string.txt_easy))
Spacer(modifier = Modifier.weight(1f))
RadioButton(
selected = difficultyLevel == DifficultyLevel.EASY,
Expand All @@ -430,7 +430,7 @@ fun CreateStudySetAITab(
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(text = "Medium")
Text(text = stringResource(R.string.txt_medium))
Spacer(modifier = Modifier.weight(1f))
RadioButton(
selected = difficultyLevel == DifficultyLevel.MEDIUM,
Expand All @@ -444,7 +444,7 @@ fun CreateStudySetAITab(
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(text = "Hard")
Text(text = stringResource(R.string.txt_hard))
Spacer(modifier = Modifier.weight(1f))
RadioButton(
selected = difficultyLevel == DifficultyLevel.HARD,
Expand Down Expand Up @@ -492,7 +492,7 @@ fun CreateStudySetAITab(
) {
Image(
painter = painterResource(id = R.drawable.ic_vn_flag),
contentDescription = "VN Flag",
contentDescription = stringResource(R.string.txt_vn_flag),
modifier = Modifier
.size(24.dp)
)
Expand All @@ -511,7 +511,7 @@ fun CreateStudySetAITab(
if (language == LanguageCode.VI.code) {
Icon(
imageVector = Icons.Default.Check,
contentDescription = "Check",
contentDescription = stringResource(R.string.txt_check),
tint = colorScheme.primary
)
}
Expand All @@ -532,7 +532,7 @@ fun CreateStudySetAITab(
) {
Image(
painter = painterResource(id = R.drawable.ic_us_flag),
contentDescription = "US Flag",
contentDescription = stringResource(R.string.txt_us_flag),
modifier = Modifier
.size(24.dp)
)
Expand All @@ -552,7 +552,7 @@ fun CreateStudySetAITab(
if (language == LanguageCode.EN.code) {
Icon(
imageVector = Icons.Default.Check,
contentDescription = "Check",
contentDescription = stringResource(R.string.txt_check),
tint = colorScheme.primary
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -86,25 +87,25 @@ fun TopStreakScreen(
) {
Image(
painter = painterResource(id = R.drawable.top2),
contentDescription = "Silver Medal",
contentDescription = stringResource(R.string.txt_silver_medal),
modifier = Modifier.size(with(density) { silverSize.value.toDp() })
)
Image(
painter = painterResource(id = R.drawable.top1),
contentDescription = "Gold Medal",
contentDescription = stringResource(R.string.txt_gold_medal),
modifier = Modifier.size(with(density) { goldSize.value.toDp() })
)
Image(
painter = painterResource(id = R.drawable.top3),
contentDescription = "Bronze Medal",
contentDescription = stringResource(R.string.txt_bronze_medal),
modifier = Modifier.size(with(density) { bronzeSize.value.toDp() })
)
}

val message = when (rankOwner) {
in 1..3 -> "You have reached the top #$rankOwner on the Top Streak leaderboard!"
in 4..10 -> "Keep up the streak to climb the leaderboard!"
else -> "Top 10 highest streak leaderboard"
in 4..10 -> stringResource(R.string.txt_keep_up_the_streak_to_climb_the_leaderboard)
else -> stringResource(R.string.txt_top_10_highest_streak_leaderboard)
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
}

Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ fun StreakItem(
when (rank) {
1 -> Image(
painter = painterResource(id = R.drawable.top1),
contentDescription = "Gold Medal",
contentDescription = stringResource(R.string.txt_gold_medal),
modifier = Modifier.size(32.dp)
)

2 -> Image(
painter = painterResource(id = R.drawable.top2),
contentDescription = "Silver Medal",
contentDescription = stringResource(R.string.txt_silver_medal),
modifier = Modifier.size(32.dp)
)

3 -> Image(
painter = painterResource(id = R.drawable.top3),
contentDescription = "Bronze Medal",
contentDescription = stringResource(R.string.txt_bronze_medal),
modifier = Modifier.size(32.dp)
)

Expand All @@ -85,7 +85,7 @@ fun StreakItem(

AsyncImage(
model = topStreak.avatarUrl,
contentDescription = "User Avatar",
contentDescription = stringResource(R.string.txt_user_avatar_top_streak),
contentScale = ContentScale.Crop,
modifier = Modifier
.size(40.dp)
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,30 @@
<string name="txt_login_description">Chào mừng trở lại! Đăng nhập vào tài khoản của bạn</string>
<string name="txt_ai_generated">Được tạo bởi AI</string>
<string name="txt_yes">Đúng</string>
<string name="txt_top_streak">Chuỗi thành tích cao nhất</string>
<string name="txt_create_study_set_ai">Tạo bộ học AI</string>
<string name="txt_gold_medal">Huy chương vàng</string>
<string name="txt_silver_medal">Huy chương bạc</string>
<string name="txt_bronze_medal">Huy chương đồng</string>
<string name="txt_user_avatar_top_streak">Ảnh đại diện người dùng</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_top_10_highest_streak_leaderboard">Bảng xếp hạng 10 chuỗi thành tích cao nhất</string>
<string name="txt_keep_up_the_streak_to_climb_the_leaderboard">Duy trì chuỗi để leo bảng xếp hạng!</string>
<string name="txt_create">Tạo</string>
<string name="txt_warning_ai_not_gen">Cảnh báo: AI có thể không tạo flashcard chính xác hoặc đầy đủ. Vui lòng kiểm tra nếu nghi ngờ.</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_title_required">Tiêu đề (bắt buộc)</string>
<string name="txt_description_optional">Mô tả (tùy chọn)</string>
<string name="txt_number_of_flashcards_optional">Số lượng flashcard (tùy chọn)</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_number_of_flashcards_5">5</string>
<string name="txt_number_of_flashcards_10">10</string>
<string name="txt_number_of_flashcards_15">15</string>
<string name="txt_number_of_flashcards_20">20</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_question_type">Loại câu hỏi</string>
<string name="txt_multiple_choice">Trắc nghiệm</string>
<string name="txt_difficulty_level">Mức độ khó</string>
<string name="txt_easy">Dễ</string>
<string name="txt_medium">Trung bình</string>
<string name="txt_hard">Khó</string>
<string name="txt_vn_flag">Cờ VN</string>
<string name="txt_check">Kiểm tra</string>
<string name="txt_us_flag">Cờ Mỹ</string>
</resources>
26 changes: 26 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,30 @@
<string name="txt_login_description">Welcome back! Log in to your account</string>
<string name="txt_ai_generated">AI Generated</string>
<string name="txt_yes">Yes</string>
<string name="txt_top_streak">Top Streak</string>
<string name="txt_create_study_set_ai">Create Study Set AI</string>
<string name="txt_gold_medal">Gold Medal</string>
<string name="txt_silver_medal">Silver Medal</string>
<string name="txt_bronze_medal">Bronze Medal</string>
<string name="txt_user_avatar_top_streak">User Avatar</string>
<string name="txt_top_10_highest_streak_leaderboard">Top 10 highest streak leaderboard</string>
<string name="txt_keep_up_the_streak_to_climb_the_leaderboard">Keep up the streak to climb the leaderboard!</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_create">Create</string>
<string name="txt_warning_ai_not_gen">Warning: AI may not generate accurate or complete flashcards. Please review if unsure.</string>
<string name="txt_title_required">Title (required)</string>
<string name="txt_description_optional">Description (optional)</string>
<string name="txt_number_of_flashcards_optional">Number of flashcards (optional)</string>
<string name="txt_number_of_flashcards_5">5</string>
<string name="txt_number_of_flashcards_10">10</string>
<string name="txt_number_of_flashcards_15">15</string>
<string name="txt_number_of_flashcards_20">20</string>
<string name="txt_question_type">Question type</string>
<string name="txt_multiple_choice">Multiple choice</string>
<string name="txt_difficulty_level">Difficulty level</string>
<string name="txt_easy">Easy</string>
<string name="txt_medium">Medium</string>
<string name="txt_hard">Hard</string>
<string name="txt_vn_flag">VN Flag</string>
nqmgaming marked this conversation as resolved.
Show resolved Hide resolved
<string name="txt_check">Check</string>
<string name="txt_us_flag">US Flag</string>
</resources>