சிறந்த நடைமுறைகள்
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
.