diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json
index aa5e635c..1248ac72 100644
--- a/public/locales/ru/translation.json
+++ b/public/locales/ru/translation.json
@@ -30,6 +30,7 @@
"All articles": "Все материалы",
"All authors": "Все авторы",
"All posts": "Все публикации",
+ "All posts rating": "Рейтинг всех постов",
"All topics": "Все темы",
"Almost done! Check your email.": "Почти готово! Осталось подтвердить вашу почту.",
"Are you sure you want to delete this comment?": "Уверены, что хотите удалить этот комментарий?",
diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx
index bb2c2cad..edd2a4fd 100644
--- a/src/components/Article/Comment/Comment.tsx
+++ b/src/components/Article/Comment/Comment.tsx
@@ -11,7 +11,7 @@ import { Author, Reaction, ReactionKind } from '../../../graphql/schema/core.gen
import { router } from '../../../stores/router'
import { Icon } from '../../_shared/Icon'
import { ShowIfAuthenticated } from '../../_shared/ShowIfAuthenticated'
-import { AuthorLink } from '../../Author/AhtorLink'
+import { AuthorLink } from '../../Author/AuthorLink'
import { Userpic } from '../../Author/Userpic'
import { CommentDate } from '../CommentDate'
import { CommentRatingControl } from '../CommentRatingControl'
diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx
index 5986e07e..8f6a928c 100644
--- a/src/components/Author/AuthorBadge/AuthorBadge.tsx
+++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx
@@ -11,9 +11,12 @@ import { Button } from '../../_shared/Button'
import { CheckButton } from '../../_shared/CheckButton'
import { Icon } from '../../_shared/Icon'
import { Userpic } from '../Userpic'
+import { translit } from '../../../utils/ru2en'
import styles from './AuthorBadge.module.scss'
import stylesButton from '../../_shared/Button/Button.module.scss'
+import { capitalize } from '../../../utils/capitalize'
+import { isCyrillic } from '../../../utils/cyrillic'
type Props = {
author: Author
@@ -30,7 +33,7 @@ export const AuthorBadge = (props: Props) => {
actions: { loadSubscriptions, requireAuthentication },
} = useSession()
const { changeSearchParams } = useRouter()
- const { t, formatDate } = useLocalize()
+ const { t, formatDate, lang } = useLocalize()
const subscribed = createMemo(() =>
subscriptions().authors.some((a: Author) => a.slug === props.author.slug),
)
@@ -60,19 +63,27 @@ export const AuthorBadge = (props: Props) => {
}, 'discussions')
}
+ const name = createMemo(() =>
+ capitalize(
+ lang() === 'en' && isCyrillic(props.author.name)
+ ? translit(props.author.name)
+ : props.author.name || '',
+ ),
+ )
+
return (
diff --git a/src/components/Author/AhtorLink/index.ts b/src/components/Author/AuthorLink/index.ts
similarity index 100%
rename from src/components/Author/AhtorLink/index.ts
rename to src/components/Author/AuthorLink/index.ts
diff --git a/src/components/Feed/ArticleCard/ArticleCard.tsx b/src/components/Feed/ArticleCard/ArticleCard.tsx
index ccc5503a..3d452ffa 100644
--- a/src/components/Feed/ArticleCard/ArticleCard.tsx
+++ b/src/components/Feed/ArticleCard/ArticleCard.tsx
@@ -15,7 +15,7 @@ import { Popover } from '../../_shared/Popover'
import { CoverImage } from '../../Article/CoverImage'
import { getShareUrl, SharePopup } from '../../Article/SharePopup'
import { ShoutRatingControl } from '../../Article/ShoutRatingControl'
-import { AuthorLink } from '../../Author/AhtorLink'
+import { AuthorLink } from '../../Author/AuthorLink'
import { CardTopic } from '../CardTopic'
import { FeedArticlePopup } from '../FeedArticlePopup'
diff --git a/src/components/Views/AllAuthors.tsx b/src/components/Views/AllAuthors.tsx
index 1390f47a..e59e8360 100644
--- a/src/components/Views/AllAuthors.tsx
+++ b/src/components/Views/AllAuthors.tsx
@@ -15,6 +15,8 @@ import { SearchField } from '../_shared/SearchField'
import { AuthorBadge } from '../Author/AuthorBadge'
import styles from './AllAuthors.module.scss'
+import { isCyrillic } from '../../utils/cyrillic'
+import { capitalize } from '../../utils/capitalize'
type AllAuthorsPageSearchParams = {
by: '' | 'name' | 'shouts' | 'followers'
@@ -26,10 +28,11 @@ type Props = {
}
const PAGE_SIZE = 20
-const ALPHABET = [...'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ@']
export const AllAuthorsView = (props: Props) => {
const { t, lang } = useLocalize()
+ const ALPHABET =
+ lang() === 'ru' ? [...'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ@'] : [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ@']
const [offsetByShouts, setOffsetByShouts] = createSignal(0)
const [offsetByFollowers, setOffsetByFollowers] = createSignal(0)
const { searchParams, changeSearchParams } = useRouter
()
@@ -73,20 +76,24 @@ export const AllAuthorsView = (props: Props) => {
shouts: loadMoreByShouts,
followers: loadMoreByFollowers,
}[searchParams().by]()
-
+ const translate = (author: Author) =>
+ lang() === 'en' && isCyrillic(author.name)
+ ? capitalize(author.slug.replace(/-/, ' '), true)
+ : author.name
const byLetter = createMemo<{ [letter: string]: Author[] }>(() => {
return sortedAuthors().reduce(
(acc, author) => {
let letter = ''
- if (author && author.name) {
- const nameParts = author.name.trim().split(' ')
- const lastName = nameParts.pop()
- if (lastName && lastName.length > 0) {
- letter = lastName[0].toUpperCase()
+ if (!letter && author && author.name) {
+ const name = translate(author)
+ const nameParts = name.trim().split(' ')
+ const found = nameParts.filter(Boolean).pop()
+ if (found && found.length > 0) {
+ letter = found[0].toUpperCase()
}
}
-
if (/[^ËА-яё]/.test(letter) && lang() === 'ru') letter = '@'
+ if (/[^A-z]/.test(letter) && lang() === 'en') letter = '@'
if (!acc[letter]) acc[letter] = []
@@ -193,7 +200,7 @@ export const AllAuthorsView = (props: Props) => {
{(author) => (
-
{author.name}
+
{translate(author)}
{author.stat.shouts}
diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx
index cd81ff8d..637115ce 100644
--- a/src/components/Views/Author/Author.tsx
+++ b/src/components/Views/Author/Author.tsx
@@ -189,7 +189,7 @@ export const AuthorView = (props: Props) => {
- {t('Karma')}
+ {t('All posts rating')}
diff --git a/src/components/Views/Feed/Feed.tsx b/src/components/Views/Feed/Feed.tsx
index 93577c99..ebfa89a3 100644
--- a/src/components/Views/Feed/Feed.tsx
+++ b/src/components/Views/Feed/Feed.tsx
@@ -18,7 +18,7 @@ import { DropDown } from '../../_shared/DropDown'
import { Icon } from '../../_shared/Icon'
import { Loading } from '../../_shared/Loading'
import { CommentDate } from '../../Article/CommentDate'
-import { AuthorLink } from '../../Author/AhtorLink'
+import { AuthorLink } from '../../Author/AuthorLink'
import { AuthorBadge } from '../../Author/AuthorBadge'
import { ArticleCard } from '../../Feed/ArticleCard'
import { Sidebar } from '../../Feed/Sidebar'