சிறந்த நடைமுறைகள்
URL-களை மாறிலிகளில் வைக்கவும்
URL-கள் அல்லது அதே போன்ற தரவுகளை உள்ளடக்கிய சரங்களை மொழிபெயர்க்கும் போது, இந்த URL-களை மாறிலிகளில் வைக்கவும், பின்னர் உங்கள் டெம்ப்ளேட்களில் அவற்றை குறிக்கவும் இது நல்ல ஒழுங்கு ஆகும் என கருதப்படுகிறது.
<Translate
string={`Click <a href="{{url}}">here</a>`}
variables={{url: 'https://tacotranslate.com'}}
/>
ARIA லேபிள்களைப் பயன்படுத்துங்கள்
பட்டன்கள் போன்ற இடைமுகlement்கள் கொண்ட உரைகளை மொழிபெயர்க்கும்போது, அணுகல் வசதியை உறுதிப்படுத்த ARIA லேபல்கள் சேர்க்கும் முக்கியத்துவம் உள்ளது. ARIA லேபல்கள் திரைத்தொடுப்பிகள் (screen readers) அந்த எலெமண்ட் செயல்பாடு பற்றிய விளக்கமான தகவலை வழங்க உதவுகின்றன.
உதாரணமாக, ஒரு பட்டன் பயனர்களுக்கு கோட் பிளாக்கிலிருந்து உரையை நகலெடுக்க விடுகின்றதாக இருந்தால், நீங்கள் 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
.