TacoTranslate
/
ਦਸਤਾਵੇਜ਼ਕਿਮਤਾਂ
 
  1. ਪ੍ਰਸਥਾਵਨਾ
  2. ਸ਼ੁਰੂਆਤ ਕਰਨਾ
  3. ਸੈੱਟਅੱਪ ਅਤੇ ਸੰਰਚਨਾ
  4. TacoTranslate ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹੋਏ
  5. ਸਰਵਰ-ਸਾਈਡ ਰੇਂਡਰਿੰਗ
  6. ਅਧੁਨਿਕ ਵਰਤੋਂ
  7. ਸਰਵੋਤਮ ਅਭਿਆਸ
  8. ਗਲਤੀ ਸੰਭਾਲ ਅਤੇ ਡੀਬੱਗਿੰਗ
  9. ਸਮਰਥਿਤ ਭਾਸ਼ਾਵਾਂ

ਸਰਵੋਤਮ ਅਭਿਆਸ

URLs ਨੂੰ ਵੈਰੀਏਬਲਾਂ ਵਿੱਚ ਰੱਖੋ

ਜਦੋਂ URL ਜਾਂ ਇਸੇ ਤਰ੍ਹਾਂ ਦੇ ਡਾਟਾ ਵਾਲੇ ਸਟਰਿੰਗਾਂ ਦਾ ਅਨੁਵਾਦ ਕੀਤਾ ਜਾਵੇ, ਤਾਂ ਇਹ ਇੱਕ ਵਧੀਆ ਅਮਲ ਸਮਝਿਆ ਜਾਂਦਾ ਹੈ ਕਿ ਇਹ 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 ਦੀ ਵਰਤੋਂ ਦੌਰਾਨ ਹੀ ਕੰਮ ਕਰਦਾ ਹੈ।

ਵੱਡੇ ਐਪਲਿਕੇਸ਼ਨਾਂ 'ਤੇ ਕੰਮ ਕਰਦੇ ਸਮੇਂ, ਸਟ੍ਰਿੰਗਜ਼ ਅਤੇ ਅਨੁਵਾਦਾਂ ਨੂੰ ਕਈ ਛੋਟੇ, ਵੱਖ-ਵੱਖ origins ਵਿੱਚ ਵੰਡਣਾ ਲਾਭਦਾਇਕ ਹੁੰਦਾ ਹੈ। ਇਹ ਤਰੀਕਾ ਬੰਡਲ ਸਾਈਜ਼ ਅਤੇ ਟਰਾਂਸਫਰ ਸਮੇਂ ਨੂੰ ਘਟਾਉਂਦਾ ਹੈ, ਜਿਹੜਾ ਕੁਸ਼ਲ ਅਤੇ ਵਧੇਰੇ ਕਾਰਗਰ ਸਥਾਨਕੀਕਰਨ ਨੂੰ ਯਕੀਨੀ ਬਣਾਉਂਦਾ ਹੈ।

ਜਦੋਂ ਸਿਰਫ ਕਲਾਇੰਟ ਸਾਈਡ 'ਤੇ ਰੈਂਡਰਿੰਗ ਕੀਤੀ ਜਾਂਦੀ ਹੈ ਤਾਂ ਇਹ ਸਿੱਧਾ ਹੁੰਦਾ ਹੈ, ਪਰ ਸਰਵਰ-ਸਾਈਡ ਰੈਂਡਰਿੰਗ ਲਈ ਅਨੁਵਾਦ ਪ੍ਰਾਪਤ ਕਰਦਿਆਂ origins ਦਾ ਪ੍ਰਬੰਧਨ ਜਲਦੀ ਹੀ ਜਟਿਲ ਹੋ ਜਾਂਦਾ ਹੈ। ਹਾਲਾਂਕਿ, ਤੁਸੀਂ 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 ਵੱਲੋਂਨਾਰਵੇ ਵਿੱਚ ਬਣਾਇਆ ਗਿਆ