TacoTranslate
/
డాక్యుమెంటేషన్ధరలు
 
  1. పరిచయం
  2. ప్రారంభించండి
  3. సెట్టప్ మరియు కాన్ఫిగరేషన్
  4. TacoTranslate ఉపయోగించడం
  5. సర్వర్-సైట్ రేండరింగ్
  6. అధునాతన వినియోగం
  7. ఉత్తమ పద్ధతులు
  8. తప్పుడు నిర్వహణ మరియు డీబగ్గింగ్
  9. మద్దతు ఉన్న భాషలు

ఉత్తమ పద్ధతులు

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 array ను ఉపయోగించి మూలాల నిర్వహణను స్వయంచాలకంగా చేయవచ్చు.

ఇదే ఒక ఉదాహరణగా చూడండి, ఇక్కడ మేము మా కంపోనెంట్లు మరియు పేజీలను వేర్వేరు ఫైళ్లుగా విడగొట్టాము.

components/pricing-table.tsx
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>
	);
}
pages/pricing.tsx
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 గురించి మరింత సమాచారం కోసం మా సర్వర్-సైడ్ రేండరింగ్ ఉదాహరణలు చూడండి.

తప్పుడు నిర్వహణ మరియు డీబగ్గింగ్

ఒక ఉత్పత్తి Nattskiftet నుండినార్వేలో తయారైనది