சிறந்த நடைமுறைகள்
URLகளை மாறிலியில் வைக்கவும்
URL களை அல்லது அதற்கு இணையான தரவுகளை கொண்ட ஸ்டிரிங்களை மொழிமாற்றம் செய்யும் போது, இந்த URL களை மாறிலிகளுக்குள் வைப்பது மற்றும் பிறகு உங்கள் டெம்பிளேட்டுகளில் அவற்றை குறியிடுவது நல்ல நடைமுறையாக கருதப்படுகிறது.
<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
.