TacoTranslate
/
દસ્તાવેજીકરણકિંમત
 
  1. પરિચય
  2. શરૂઆત
  3. સેટઅપ અને રૂપરેખાંકન
  4. TacoTranslate નો ઉપયોગ
  5. સર્વર-સાઇડ રેન્ડરિંગ
  6. ઉન્નત ઉપયોગ
  7. શ્રેષ્ઠ પ્રથાઓ
  8. ત્રુટિ સંભાળ અને ડિબગિંગ
  9. સમર્થિત ભાષાઓ

શ્રેષ્ઠ પ્રથાઓ

URL-ઓને વેરિએબલ્સમાં મૂકો

URLs અથવા સમાન માહિતી ધરાવતી સ્ટ્રિંગ્સનું અનુવાદ કરતી વખતે, આ URLs ને વેરિએબલોમાં મૂકવી અને પછી તમારા ટેમ્પલેટ્સમાં તેમને રેફરન્સ કરવી સારી પ્રથા ગણાય છે.

<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 એરેનો ઉપયોગ કરીને ઓરિજિન મેનેજમેન્ટ ઓટોમેટ કરી શકો છો.

આ ઉદાહરણ વિચારો, જેમાં અમે våra ઘટકો અને પૃષ્ઠોને અલગ ફાઇલોમાં અલગ કર્યા છે.

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 દ્વારા બનાવાયેલ ઉત્પાદનનોર્વેમાં બનાવેલ