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 એરેનો ઉપયોગ કરીને ઊત્સોનું સંચાલન આપમેળે કરી શકો છો.

આ ઉદાહరణ પર غور કરો, જ્યાં અમે અમારા કમ્પોનન્ટ્સ અને પેજોને અલગ ફાઇલોમાં વહેંચ્યા છે.

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