சிறந்த நடைமுறைகள்
URL-களை மாறிலிகளாக வைள்
URLகள் அல்லது அதேபோன்ற தரவு கொண்ட stringsஐ மொழிபெயர்க்கும்போது, அவற்றை variablesகளில் வைக்கவும் பின்னர் உங்கள் templates களில் அவர்களை குறிக்கவும் இது ஒரு நல்ல நடைமுறையாகக் கருதப்படுகிறது.
<Translate
string={`Click <a href="{{url}}">here</a>`}
variables={{url: 'https://tacotranslate.com'}}
/>
ARIA லேபிள்களை பயன்படுத்தவும்
பட்டன் போன்ற தொடர்ச்சியான கூறுகளின் உரையை மொழிபெயர்ப்பதில், அணுகலை உறுதிப்படுத்த ARIA லேபெல்களை சேர்ப்பது முக்கியம். ARIA லேபெல்கள் ஸ்கிரீன் ரீடர்கள் கூறும் செயல்பாட்டின் குறிப்பு தகவலை வழங்க உதவுகின்றன.
உதाहरणமாக, குறியீட்டு பகுதியிலிருந்து உரையை நகலை செய்யக்கூடிய ஒரு பட்டன் இருந்தால், நீங்கள் தெளிவான விளக்கத்திற்காக aria-label
பண்பை பயன்படுத்தலாம்:
<Translate
aria-label={useTranslation('Copy to clipboard')}
string="Copy"
/>
இதில் எதோ ஒரு மிகவும் மேட்டா உணர்வு உள்ளது.
உலகளாவிய மூலங்கள் வரிசையும் பல கூறுகளின் மூலங்களும்
இந்த இயக்கம் Next.js Pages Router பயன்படுத்தும் போது மட்டுமே செயல்படும்.
பெரிய செயலிகளில் வேலைசெய்யும் போது, சரங்கள் மற்றும் மொழிபெயர்ப்புகளை பல சிறிய ஊர்களாகப் பிரிப்பது பயனுள்ளதாகும். இந்த முறையால் தொகுப்புக் கோப்புகளின் அளவும் அனுப்பும் நேரமும் குறைகிறது, இதனால் திறமையான மற்றும் விரிவாக்கக்கூடிய மொழிபெயர்ப்பு உறுதி செய்யப்படுகிறது.
இது வாடிக்கையாளர் பக்கத்தில் மட்டுமே வரையறுக்கும்போது நேரடியாக இருப்பதற்கிடையில், சேவையகப் பக்க வரையறைக்கு மொழிபெயர்ப்புகளை பெறும் போது ஊர்களை நிர்வகிப்பது விரைவில் சிக்கலாக மாறுகிறது. இருப்பினும், TacoTranslate வாடிக்கையாளர் origins
வரிசையைப் பயன்படுத்தி ஊர் நிர்வகிப்பை தானாகச் செயற்படுத்தலாம்.
நம்மில் கூறு மற்றும் பக்கங்களை தனித்தனியான கோப்புகளில் பிரித்துள்ளோம் என்ற இந்த எடுத்துக்காட்டைப் பரிசீலியுங்கள்.
import TacoTranslate, {Translate} from 'tacotranslate/react';
import tacoTranslate from '../tacotranslate-client';
// Set an origin name for this component
const origin = 'components/pricing-table';
// Push the origin into the origins array as this file is imported
tacoTranslate.origins.push(origin);
export default function PricingTable() {
return (
<TacoTranslate origin={origin}>
<Translate string="Pricing table" />
// ...
</TacoTranslate>
);
}
import TacoTranslate, {Translate} from 'tacotranslate/react';
import getTacoTranslateStaticProps from 'tacotranslate/next/get-static-props';
import tacoTranslateClient from '../tacotranslate-client';
import PricingTable from '../components/pricing-table';
const origin = 'pages/pricing';
tacoTranslateClient.origins.push(origin);
export default function PricingPage() {
return (
<TacoTranslate origin={origin}>
<Translate string="Pricing page" />
<PricingTable />
</TacoTranslate>
);
}
// We will now fetch translations for all imported components and their origins automatically
export async function getStaticProps(context) {
return getTacoTranslateStaticProps(context, {client: tacoTranslateClient});
}
மேலும் தகவலுக்கு, எங்கள் சர்வர்-பக்கம் ரென்டரிங் உதாரணங்களை பாருங்கள் getTacoTranslateStaticProps
.