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

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

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

જ્યારે 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"
/>

આમાં કંઈક તો ખૂબ જ મેટા લાગે છે.

ગ્લોબલ ઓરિજિન્સ એરે અને πολλIPLE COMPONENT ઓરિજિન્સ

આ પેટર્ન માત્ર Next.js Pages Router ઉપયોગ કરતી વખતે જ કામ કરે છે.

જ્યારે મોટા એપ્લિકેશન્સ સાથે કામ કરવું હોય, ત્યારે સ્ટ્રિંગ્સ અને અનુવાદોને ઘણા નાના અને અલગ-અલગ મૂળોમાં વહેંચવું લાભદાયક હોય છે. આ પદ્ધતિ બન્ડલ કદ અને ટ્રાન્સફર સમય ઘટાડવામાં મદદ કરે છે, જે પ્રભાવી અને સ્કેલેબલ લોકલાઇઝેશનને સુનિશ્ચિત કરે છે.

જ્યારે આ માત્ર ક્લાયંટ સાઇડ પર રેન્ડરિંગ કરતી વખતે સીધી અને સરળ હોય છે, ત્યારે સર્વર-સાઇડ રેન્ડરિંગ માટે અનુવાદ લાવતી વખતે મૂળોની વ્યવસ્થા ઝડપથી જટિલ બની જાય છે. તેમ છતાં, તમે TacoTranslate ક્લાયંટ origins એરેનો ઉપયોગ કરીને મૂળોની વ્યવસ્થાને સ્વચાલિત કરી શકો છો.

આ ઉદાહરણ પર વિચાર કરો, જ્યાં અમે અમારા ઘટકો અને પાનાઓને અલગ ફાઈલોમાં વિભાજિત કર્યા છે.

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 નું એક પ્રોડકટનோரવે માં બનાવાયું