ਉੱਤਮ ਅਭਿਆਸ
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
ਐਰੇ ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਓਰਿਜਿਨਜ਼ ਦੇ ਪ੍ਰਬੰਧ ਨੂੰ ਆਟੋਮੇਟ ਕਰ ਸਕਦੇ ਹੋ।
ਇਸ ਉਦਾਹਰਨ ਨੂੰ ਦੇਖੋ, ਜਿੱਥੇ ਅਸੀਂ ਆਪਣੇ ਕੰਪੋਨੈਂਟ ਅਤੇ ਪੰਨਿਆਂ ਨੂੰ ਵੱਖ-ਵੱਖ ਫਾਈਲਾਂ ਵਿੱਚ ਵੰਡ ਦਿੱਤਾ ਹੈ।
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>
);
}
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
ਬਾਰੇ ਹੋਰ ਜਾਣਕਾਰੀ ਲਈ.