TacoTranslate
/
ડોક્યૂમેન્ટેશનકિંમતનુ
 
  1. પરિચય
  2. શરુઆત કરવી
  3. સેટઅપ અને સંરચના
  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"
/>

આમાં કંઇક ખૂબ મેટા લાગે છે.

ગ્લોબલ ઓરિજિન્સ એરે અને બહુવિધ ઘટક ઓરિજિન્સ

આ પેટર્ન ફક્ત 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 તરફનું એક ઉત્પાદન