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

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

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

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

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

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