mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-07-29 05:01:24 +00:00
Add processor for i18next
This commit is contained in:
@@ -684,7 +684,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
sx={{ textAlign: 'center' }}
|
sx={{ textAlign: 'center' }}
|
||||||
>
|
>
|
||||||
{t('core:minting.blockchain_statistics', {
|
{t('core:minting.blockchain_statistics', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
@@ -696,7 +696,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
>
|
>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.average_blocktime', {
|
label={t('core:minting.average_blocktime', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={averageBlockTime(
|
value={averageBlockTime(
|
||||||
adminInfo,
|
adminInfo,
|
||||||
@@ -706,7 +706,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
|
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.average_blocks_per_day', {
|
label={t('core:minting.average_blocks_per_day', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={averageBlockDay(
|
value={averageBlockDay(
|
||||||
adminInfo,
|
adminInfo,
|
||||||
@@ -716,7 +716,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
|
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.average_created_qorts_per_day', {
|
label={t('core:minting.average_created_qorts_per_day', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={dayReward(
|
value={dayReward(
|
||||||
adminInfo,
|
adminInfo,
|
||||||
@@ -743,7 +743,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
sx={{ textAlign: 'center' }}
|
sx={{ textAlign: 'center' }}
|
||||||
>
|
>
|
||||||
{t('core:minting.account_details', {
|
{t('core:minting.account_details', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
@@ -755,19 +755,19 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
>
|
>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.current_status', {
|
label={t('core:minting.current_status', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={mintingStatus(nodeStatus)}
|
value={mintingStatus(nodeStatus)}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.current_level', {
|
label={t('core:minting.current_level', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={accountInfo?.level}
|
value={accountInfo?.level}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.blocks_next_level', {
|
label={t('core:minting.blocks_next_level', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={
|
value={
|
||||||
levelUpBlocks(accountInfo, nodeStatus).toFixed(0) || ''
|
levelUpBlocks(accountInfo, nodeStatus).toFixed(0) || ''
|
||||||
@@ -810,7 +810,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
sx={{ textAlign: 'center' }}
|
sx={{ textAlign: 'center' }}
|
||||||
>
|
>
|
||||||
{t('core:minting.rewards_info', {
|
{t('core:minting.rewards_info', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
@@ -822,13 +822,13 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
>
|
>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.current_tier', {
|
label={t('core:minting.current_tier', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={currentTier(accountInfo?.level) || ''}
|
value={currentTier(accountInfo?.level) || ''}
|
||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.total_minter_in_tier', {
|
label={t('core:minting.total_minter_in_tier', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={
|
value={
|
||||||
countMintersInLevel(
|
countMintersInLevel(
|
||||||
@@ -840,7 +840,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.tier_share_per_block', {
|
label={t('core:minting.tier_share_per_block', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={
|
value={
|
||||||
tierPercent(accountInfo, tier4Online)?.toFixed(0) + ' %'
|
tierPercent(accountInfo, tier4Online)?.toFixed(0) + ' %'
|
||||||
@@ -848,7 +848,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.reward_per_block', {
|
label={t('core:minting.reward_per_block', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={
|
value={
|
||||||
countReward(
|
countReward(
|
||||||
@@ -861,7 +861,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
/>
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label={t('core:minting.reward_per_day', {
|
label={t('core:minting.reward_per_day', {
|
||||||
postProcess: 'capitalizeFirstChar',
|
postProcess: 'capitalizeEachFirstChar',
|
||||||
})}
|
})}
|
||||||
value={
|
value={
|
||||||
countRewardDay(
|
countRewardDay(
|
||||||
|
@@ -4,6 +4,7 @@ import HttpBackend from 'i18next-http-backend';
|
|||||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
import {
|
import {
|
||||||
capitalizeAll,
|
capitalizeAll,
|
||||||
|
capitalizeEachFirstChar,
|
||||||
capitalizeFirstChar,
|
capitalizeFirstChar,
|
||||||
capitalizeFirstWord,
|
capitalizeFirstWord,
|
||||||
} from './processors';
|
} from './processors';
|
||||||
@@ -42,6 +43,7 @@ i18n
|
|||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.use(capitalizeAll as any)
|
.use(capitalizeAll as any)
|
||||||
|
.use(capitalizeEachFirstChar as any)
|
||||||
.use(capitalizeFirstChar as any)
|
.use(capitalizeFirstChar as any)
|
||||||
.use(capitalizeFirstWord as any)
|
.use(capitalizeFirstWord as any)
|
||||||
.init({
|
.init({
|
||||||
|
@@ -324,7 +324,7 @@
|
|||||||
"blocks_next_level": "блоков до следующего уровня",
|
"blocks_next_level": "блоков до следующего уровня",
|
||||||
"current_level": "текущий уровень",
|
"current_level": "текущий уровень",
|
||||||
"current_status": "текущий статус",
|
"current_status": "текущий статус",
|
||||||
"current_tier": "текущий уровень (tier)",
|
"current_tier": "текущий уровень",
|
||||||
"details": "детали майнинга",
|
"details": "детали майнинга",
|
||||||
"next_level": "При майнинге 24/7 вы достигнете <strong>{{ level }} уровня</strong> за <strong>{{ count }} дней</strong>",
|
"next_level": "При майнинге 24/7 вы достигнете <strong>{{ level }} уровня</strong> за <strong>{{ count }} дней</strong>",
|
||||||
"rewards_info": "информация о наградах за майнинг",
|
"rewards_info": "информация о наградах за майнинг",
|
||||||
@@ -343,7 +343,7 @@
|
|||||||
},
|
},
|
||||||
"name": "имя",
|
"name": "имя",
|
||||||
"name_app": "имя/приложение",
|
"name_app": "имя/приложение",
|
||||||
"new_post_in": "new post in {{ title }}",
|
"new_post_in": "новые сообщения в {{ title }}",
|
||||||
"none": "никто",
|
"none": "никто",
|
||||||
"note": "примечание",
|
"note": "примечание",
|
||||||
"option": "вариант",
|
"option": "вариант",
|
||||||
|
@@ -4,6 +4,20 @@ export const capitalizeAll = {
|
|||||||
process: (value: string) => value.toUpperCase(),
|
process: (value: string) => value.toUpperCase(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const capitalizeEachFirstChar = {
|
||||||
|
type: 'postProcessor',
|
||||||
|
name: 'capitalizeEachFirstChar',
|
||||||
|
process: (value: string) => {
|
||||||
|
if (!value?.trim()) return value;
|
||||||
|
|
||||||
|
const leadingSpaces = value.match(/^\s*/)?.[0] || '';
|
||||||
|
const trailingSpaces = value.match(/\s*$/)?.[0] || '';
|
||||||
|
const core = value.trim().replace(/\b\w/g, (char) => char.toUpperCase());
|
||||||
|
|
||||||
|
return leadingSpaces + core + trailingSpaces;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const capitalizeFirstChar = {
|
export const capitalizeFirstChar = {
|
||||||
type: 'postProcessor',
|
type: 'postProcessor',
|
||||||
name: 'capitalizeFirstChar',
|
name: 'capitalizeFirstChar',
|
||||||
|
Reference in New Issue
Block a user