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

Added Japanese Translation Strings #686

Merged
merged 5 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
39 changes: 39 additions & 0 deletions app/src/main/java/com/jerboa/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,9 @@ fun getLocalizedSortingTypeName(context: Context, sortingType: SortType): String
return returnString
}

/**
* Returns localized Strings for UserTab Enum
*/
fun getLocalizedStringForUserTab(ctx: Context, tab: UserTab): String {
val returnString = when (tab) {
UserTab.About -> ctx.getString(R.string.person_profile_activity_about)
Expand All @@ -991,3 +994,39 @@ fun getLocalizedStringForUserTab(ctx: Context, tab: UserTab): String {
}
return returnString
}

/**
* Returns localized Strings for ListingType Enum
*/
fun getLocalizedListingTypeName(context: Context, listingType: ListingType): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the convention above: ctx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks for the heads up. I was looking for a convention to follow for naming, I found in Utils.kt context: Context instead of ctx was being used in convertSpToPx and getLocalizedSortinTypeName methods so I was following that. I'll make the fixes now and try to push them to this branch.

val returnString = when (listingType) {
ListingType.All -> context.getString(R.string.home_all)
ListingType.Local -> context.getString(R.string.home_local)
ListingType.Subscribed -> context.getString(R.string.home_subscribed)
}
return returnString
}

/**
* Returns localized Strings for CommentSortType Enum
*/
fun getLocalizedCommentSortTypeName(context: Context, commentSortType: CommentSortType): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

val returnString = when (commentSortType) {
CommentSortType.Hot -> context.getString(R.string.sorttype_hot)
CommentSortType.New -> context.getString(R.string.sorttype_new)
CommentSortType.Old -> context.getString(R.string.sorttype_old)
CommentSortType.Top -> context.getString(R.string.dialogs_top)
}
return returnString
}

/**
* Returns localized Strings for UnreadOrAll Enum
*/
fun getLocalizedUnreadOrAllName(context: Context, unreadOrAll: UnreadOrAll): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

val returnString = when (unreadOrAll) {
UnreadOrAll.Unread -> context.getString(R.string.dialogs_unread)
UnreadOrAll.All -> context.getString(R.string.dialogs_all)
}
return returnString
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
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.navigation.NavController
Expand All @@ -18,6 +19,7 @@ import com.jerboa.datatypes.CommunityView
import com.jerboa.datatypes.SortType
import com.jerboa.datatypes.SubscribedType
import com.jerboa.datatypes.sampleCommunityView
import com.jerboa.getLocalizedSortingTypeName
import com.jerboa.ui.components.common.DefaultBackButton
import com.jerboa.ui.components.common.IconAndTextDrawerItem
import com.jerboa.ui.components.common.LargerCircularIcon
Expand Down Expand Up @@ -207,13 +209,14 @@ fun CommunityHeaderTitle(
communityName: String,
selectedSortType: SortType,
) {
val context = LocalContext.current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx

Column {
Text(
text = communityName,
style = MaterialTheme.typography.titleLarge,
)
Text(
text = selectedSortType.toString(),
text = getLocalizedSortingTypeName(context, selectedSortType),
style = MaterialTheme.typography.titleMedium,
)
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
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.navigation.NavController
Expand All @@ -74,6 +75,8 @@ import com.jerboa.datatypes.api.MyUserInfo
import com.jerboa.datatypes.samplePersonSafe
import com.jerboa.db.Account
import com.jerboa.db.AccountViewModel
import com.jerboa.getLocalizedListingTypeName
import com.jerboa.getLocalizedSortingTypeName
import com.jerboa.ui.components.common.IconAndTextDrawerItem
import com.jerboa.ui.components.common.LargerCircularIcon
import com.jerboa.ui.components.common.ListingTypeOptionsDialog
Expand Down Expand Up @@ -439,13 +442,14 @@ fun HomeHeaderTitle(
selectedSortType: SortType,
selectedListingType: ListingType,
) {
val context = LocalContext.current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx

Column {
Text(
text = selectedListingType.toString(),
text = getLocalizedListingTypeName(context, selectedListingType),
style = MaterialTheme.typography.titleLarge,
)
Text(
text = selectedSortType.toString(),
text = getLocalizedSortingTypeName(context, selectedSortType),
style = MaterialTheme.typography.titleSmall,
)
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/inbox/Inbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.R
import com.jerboa.UnreadOrAll
import com.jerboa.getLocalizedUnreadOrAllName
import com.jerboa.ui.components.common.DefaultBackButton
import com.jerboa.ui.components.common.UnreadOrAllOptionsDialog

Expand Down Expand Up @@ -79,6 +81,7 @@ fun InboxHeader(
@Composable
fun InboxHeaderTitle(selectedUnreadOrAll: UnreadOrAll, unreadCount: Int? = null) {
var title = stringResource(R.string.inbox_inbox)
val context = LocalContext.current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if (unreadCount != null && unreadCount > 0) {
title = "$title ($unreadCount)"
}
Expand All @@ -88,7 +91,7 @@ fun InboxHeaderTitle(selectedUnreadOrAll: UnreadOrAll, unreadCount: Int? = null)
style = MaterialTheme.typography.titleLarge,
)
Text(
text = selectedUnreadOrAll.toString(),
text = getLocalizedUnreadOrAllName(context, selectedUnreadOrAll),
style = MaterialTheme.typography.titleMedium,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.jerboa.datatypes.CommentSortType
import com.jerboa.db.AccountViewModel
import com.jerboa.getCommentParentId
import com.jerboa.getDepthFromComment
import com.jerboa.getLocalizedCommentSortTypeName
import com.jerboa.isModerator
import com.jerboa.ui.components.comment.ShowCommentContextButtons
import com.jerboa.ui.components.comment.commentNodeItems
Expand All @@ -63,13 +64,15 @@ import com.jerboa.ui.components.post.edit.PostEditViewModel
fun CommentsHeaderTitle(
selectedSortType: CommentSortType,
) {
val context = LocalContext.current
Column {
Text(
text = stringResource(R.string.post_activity_comments),
style = MaterialTheme.typography.titleLarge,
)
Text(
text = selectedSortType.toString(),

text = getLocalizedCommentSortTypeName(context, selectedSortType),
style = MaterialTheme.typography.titleSmall,
)
}
Expand Down
Loading