Skip to content

Commit

Permalink
feat(language): đa ngôn ngữ (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: Daocon <[email protected]>
Co-authored-by: Nguyễn Quang Minh (NQM) <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 30, 2024
1 parent 857b2d3 commit 9648602
Show file tree
Hide file tree
Showing 61 changed files with 500 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.pwhs.quickmem.R
import com.pwhs.quickmem.domain.model.folder.GetFolderResponseModel
import com.pwhs.quickmem.presentation.app.classes.add_folder.component.AddFolderToClassList
import com.pwhs.quickmem.presentation.app.classes.add_folder.component.AddFolderToClassTopAppBar
Expand Down Expand Up @@ -103,7 +105,7 @@ fun AddFolderToClass(
AddFolderToClassTopAppBar(
onDoneClick = onDoneClick,
onNavigateCancel = onNavigateCancel,
title = "Add Folder"
title = stringResource(R.string.txt_add_folder)
)
},
floatingActionButton = {
Expand All @@ -114,7 +116,7 @@ fun AddFolderToClass(
) {
Icon(
imageVector = Icons.Default.Add,
contentDescription = "Create Folder"
contentDescription = stringResource(R.string.txt_create_folder)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
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 @@ -42,7 +43,7 @@ import com.pwhs.quickmem.ui.theme.QuickMemTheme
@Composable
fun AddFolderToClassItem(
modifier: Modifier = Modifier,
folder : GetFolderResponseModel,
folder: GetFolderResponseModel,
isAdded: Boolean = false,
onAddFolderToClass: (String) -> Unit = {},
) {
Expand Down Expand Up @@ -76,7 +77,7 @@ fun AddFolderToClassItem(
) {
Icon(
imageVector = Outlined.Folder,
contentDescription = "Folder Icon"
contentDescription = stringResource(R.string.txt_folder),
)
Text(
text = folder.title,
Expand All @@ -90,9 +91,9 @@ fun AddFolderToClassItem(
) {
Text(
text = when (folder.studySetCount) {
0 -> "No study sets"
1 -> "1 study set"
else -> "${folder.studySetCount} study sets"
0 -> stringResource(R.string.txt_no_study_sets)
1 -> stringResource(R.string.txt_one_study_set)
else -> stringResource(R.string.txt_study_sets_library, folder.studySetCount)
},
style = typography.bodyMedium
)
Expand All @@ -109,7 +110,7 @@ fun AddFolderToClassItem(
) {
AsyncImage(
model = folder.owner.avatarUrl,
contentDescription = "User Avatar",
contentDescription = stringResource(R.string.txt_user_avatar),
modifier = Modifier
.size(24.dp)
.clip(CircleShape),
Expand All @@ -136,7 +137,9 @@ fun AddFolderToClassItem(
) {
Icon(
painter = painterResource(if (isAdded) R.drawable.ic_check_circle else R.drawable.ic_add_circle),
contentDescription = if (isAdded) "Check Icon" else "Add Icon",
contentDescription = if (isAdded) stringResource(R.string.txt_check_icon) else stringResource(
R.string.txt_add_icon
),
modifier = Modifier.size(26.dp),
tint = colorScheme.onSurface
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
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
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.pwhs.quickmem.R
import com.pwhs.quickmem.domain.model.folder.GetFolderResponseModel
import com.pwhs.quickmem.presentation.ads.BannerAds
import com.pwhs.quickmem.presentation.app.library.component.SearchTextField
Expand Down Expand Up @@ -65,7 +67,7 @@ fun AddFolderToClassList(
) {
AsyncImage(
model = avatarUrl,
contentDescription = "User avatar",
contentDescription = stringResource(R.string.txt_user_avatar),
modifier = Modifier
.size(60.dp)
.clip(CircleShape),
Expand All @@ -83,7 +85,7 @@ fun AddFolderToClassList(
color = colorScheme.onSurface.copy(alpha = 0.1f),
)
Text(
text = "There are no folders yet, create one to get started!",
text = stringResource(R.string.txt_there_are_no_folders_yet_create_one_to_get_started),
textAlign = TextAlign.Center,
style = typography.bodyMedium.copy(
color = colorScheme.onSurface.copy(alpha = 0.6f),
Expand All @@ -102,7 +104,7 @@ fun AddFolderToClassList(
SearchTextField(
searchQuery = searchQuery,
onSearchQueryChange = { searchQuery = it },
placeholder = "Search folders",
placeholder = stringResource(R.string.txt_search_folders),
)
}
}
Expand All @@ -124,7 +126,7 @@ fun AddFolderToClassList(
horizontalAlignment = CenterHorizontally
) {
Text(
text = "No folders found",
text = stringResource(R.string.txt_no_folders_found),
style = typography.bodyLarge,
textAlign = TextAlign.Center
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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.sp
import com.pwhs.quickmem.R
import com.pwhs.quickmem.ui.theme.QuickMemTheme

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -50,7 +52,7 @@ fun AddFolderToClassTopAppBar(
)
) {
Text(
text = "Done",
text = stringResource(R.string.txt_done),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold,
color = colorScheme.onSurface,
Expand All @@ -67,7 +69,7 @@ fun AddFolderToClassTopAppBar(
)
) {
Text(
text = "Cancel",
text = stringResource(R.string.txt_cancel),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold,
color = colorScheme.onSurface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.pwhs.quickmem.R
import com.pwhs.quickmem.domain.model.study_set.GetStudySetResponseModel
import com.pwhs.quickmem.presentation.app.classes.add_study_set.component.AddStudySetToClassList
import com.pwhs.quickmem.presentation.app.classes.add_study_set.component.AddStudySetToClassTopAppBar
Expand Down Expand Up @@ -103,7 +105,7 @@ fun AddStudySetToClass(
AddStudySetToClassTopAppBar(
onDoneClick = onDoneClick,
onNavigateCancel = onNavigateCancel,
title = "Add Study Set"
title = stringResource(R.string.txt_add_study_set)
)
},
floatingActionButton = {
Expand All @@ -114,7 +116,7 @@ fun AddStudySetToClass(
) {
Icon(
imageVector = Icons.Default.Add,
contentDescription = "Create Study Set"
contentDescription = stringResource(R.string.txt_create_study_set)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Scaffold
Expand Down Expand Up @@ -80,7 +79,7 @@ fun AddStudySetToClassItem(
) {
Text(
studySet.title,
style = MaterialTheme.typography.titleMedium.copy(
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
maxLines = 2,
Expand All @@ -93,14 +92,14 @@ fun AddStudySetToClassItem(
Text(
buildAnnotatedString {
withStyle(
style = MaterialTheme.typography.bodySmall.toSpanStyle()
style = typography.bodySmall.toSpanStyle()
.copy(
fontWeight = FontWeight.Bold
)
) {
append("${studySet.flashcardCount}")
withStyle(
style = MaterialTheme.typography.bodySmall.toSpanStyle()
style = typography.bodySmall.toSpanStyle()
.copy(
fontWeight = FontWeight.Normal
)
Expand All @@ -115,12 +114,12 @@ fun AddStudySetToClassItem(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = studySet?.subject?.name ?: SubjectModel.defaultSubjects[0].name,
text = studySet.subject?.name ?: SubjectModel.defaultSubjects[0].name,
style = typography.bodySmall.copy(
color = colorScheme.onSurface.copy(alpha = 0.6f)
)
)
if(studySet?.isAIGenerated == true) {
if(studySet.isAIGenerated == true) {
VerticalDivider(
modifier = Modifier.height(12.dp)
)
Expand All @@ -146,15 +145,15 @@ fun AddStudySetToClassItem(
) {
AsyncImage(
model = studySet.owner.avatarUrl,
contentDescription = "User avatar",
contentDescription = stringResource(R.string.txt_user_avatar),
contentScale = ContentScale.Crop,
modifier = Modifier
.size(18.dp)
.clip(CircleShape)
)
Text(
studySet.owner.username,
style = MaterialTheme.typography.bodySmall
style = typography.bodySmall
)
}
}
Expand All @@ -170,7 +169,9 @@ fun AddStudySetToClassItem(
) {
Icon(
painter = painterResource(if (isAdded) R.drawable.ic_check_circle else R.drawable.ic_add_circle),
contentDescription = if (isAdded) "Check Icon" else "Add Icon",
contentDescription = if (isAdded) stringResource(R.string.txt_check_icon) else stringResource(
R.string.txt_add_icon
),
modifier = Modifier.size(26.dp),
tint = colorScheme.onSurface
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
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
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.pwhs.quickmem.R
import com.pwhs.quickmem.domain.model.color.ColorModel
import com.pwhs.quickmem.domain.model.study_set.GetStudySetResponseModel
import com.pwhs.quickmem.domain.model.subject.SubjectModel
Expand Down Expand Up @@ -68,7 +70,7 @@ fun AddStudySetToClassList(
) {
AsyncImage(
model = avatarUrl,
contentDescription = "User avatar",
contentDescription = stringResource(R.string.txt_user_avatar),
modifier = Modifier
.size(60.dp)
.clip(CircleShape),
Expand All @@ -86,7 +88,7 @@ fun AddStudySetToClassList(
color = colorScheme.onSurface.copy(alpha = 0.1f),
)
Text(
text = "There are no owned study sets, create one to get started!",
text = stringResource(R.string.txt_there_are_no_owned_study_sets_create_one_to_get_started),
textAlign = TextAlign.Center,
style = typography.bodyMedium.copy(
color = colorScheme.onSurface.copy(alpha = 0.6f),
Expand All @@ -106,7 +108,7 @@ fun AddStudySetToClassList(
SearchTextField(
searchQuery = searchQuery,
onSearchQueryChange = { searchQuery = it },
placeholder = "Search study sets"
placeholder = stringResource(R.string.txt_search_study_sets),
)

}
Expand All @@ -119,7 +121,7 @@ fun AddStudySetToClassList(
horizontalAlignment = CenterHorizontally
) {
Text(
text = "No study set fold found",
text = stringResource(R.string.txt_no_study_set_folder_found),
style = typography.bodyLarge,
textAlign = TextAlign.Center
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
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.sp
import com.pwhs.quickmem.ui.theme.QuickMemTheme
import com.pwhs.quickmem.R

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -50,7 +52,7 @@ fun AddStudySetToClassTopAppBar(
)
) {
Text(
text = "Done",
text = stringResource(R.string.txt_done),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold,
color = colorScheme.onSurface,
Expand All @@ -67,7 +69,7 @@ fun AddStudySetToClassTopAppBar(
)
) {
Text(
text = "Cancel",
text = stringResource(R.string.txt_cancel),
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold,
color = colorScheme.onSurface,
Expand Down
Loading

0 comments on commit 9648602

Please sign in to comment.